temp commit

This commit is contained in:
limited_dev 2023-02-07 21:21:38 +01:00
parent f5ac34e639
commit 2724b6b9d2
14 changed files with 136 additions and 19 deletions

View file

@ -1,7 +1,6 @@
@page "/login"
@using ImageBoardServerApp.Data.Repository
@using ImageBoardServerApp.Auth
@using System.Runtime.InteropServices
@inject IJSRuntime js
@inject AuthenticationStateProvider authStateProvider
@inject NavigationManager navManager

View file

@ -0,0 +1,67 @@
@page "/register"
@using ImageBoardServerApp.Data.Repository
@using ImageBoardServerApp.Auth
@inject IJSRuntime js
@inject AuthenticationStateProvider authStateProvider
@inject NavigationManager navManager
<h3>Register to bulletbroards</h3>
<div>
<form>
<div>
<label for="email">Email:</label>
<input type="email" id="email" @bind="Email" />
</div>
<div>
<label for="password">Password:</label>
<input type="password" id="password" @bind="Password" />
</div>
<a @onclick="login" href="javascript:void(0)">[Register]</a>
</form>
</div>
@code {
private string Email { get; set; }
private string Password { get; set; }
private bool verified;
private async Task login()
{
Console.WriteLine("Registering...");
UserData userToCreate = new UserData()
{
Email = Email,
Password = BCrypt.Net.BCrypt.HashPassword(Password),
Role = "User",
PermissionInteger = 1,
TimeBanned = -1
};
if (await UsersRepository.getUserByEmailAsync(Email) != null)
{
return;
}
await UsersRepository.createUserAsync(userToCreate);
Console.WriteLine("loggin you in...");
var user = await UsersRepository.getUserByEmailAsync(Email);
if (user == null)
{
await js.InvokeVoidAsync("alert", "User does not exist");
verified = false;
return;
}
verified = BCrypt.Net.BCrypt.Verify(Password, user.Password);
if (verified)
{
verified = true;
var customAuthStateProvider = (CustomAuthenticationStateProvider)authStateProvider;
await customAuthStateProvider.UpdateAuthenticationStateAsync(user);
navManager.NavigateTo("/", true);
return;
}
await js.InvokeVoidAsync("alert", $"Wrong Password");
}
}
@code {
}

View file

@ -6,8 +6,8 @@
<h1>BulletBoard</h1>
<span>This is a simple Imageboard made in Razor.</span>
<br/>
<span>We're currently hosting @amountOfPosts Threads with @amountOfComments Comments from @amountOfUsers Users.</span>
<br/>
<span>We're currently hosting @amountOfPosts Threads, @amountOfComments Comments and @amountOfUsers Users.</span>
<sr/>
<span>@Details</span>
@code{

View file

@ -0,0 +1,31 @@
@page "/modmenu"
@using ImageBoardServerApp.Auth
@inject AuthenticationStateProvider authStateProvider
@inject NavigationManager navManager
<h3>ModMenu</h3>
<AuthorizeView>
<Authorized>
<span>Welcome @mail to the mod menu</span>
<div>
<a href="/modmenu/reports">[Reports]</a>
</div>
</Authorized>
<NotAuthorized>
<a href="/login">You do not have permission to view this menu.</a>
</NotAuthorized>
</AuthorizeView>
@code {
private string mail { get; set; } = "";
protected override async Task OnInitializedAsync()
{
var cauthStateProvder = (CustomAuthenticationStateProvider)authStateProvider;
var user = await cauthStateProvder.GetAuthenticationStateAsync();
if (user.User.Identity.IsAuthenticated)
{
mail = user.User.Identity.Name;
}
}
}

View file

@ -0,0 +1,5 @@
@page "/modmenu/reports"
<Reports />
@code {
}