feat: added docker stuff, started working on login system
This commit is contained in:
parent
c2d40c172a
commit
7c0cef6f65
15 changed files with 216 additions and 143 deletions
|
@ -1,6 +1,12 @@
|
|||
@page "/Login"
|
||||
@page "/login"
|
||||
@using ImageBoardServerApp.Data.Repository
|
||||
<h3>Login</h3>
|
||||
@using ImageBoardServerApp.Auth
|
||||
@using System.Runtime.InteropServices
|
||||
@inject IJSRuntime js
|
||||
@inject AuthenticationStateProvider authStateProvider
|
||||
@inject NavigationManager navManager
|
||||
|
||||
<h3>Login to bulletbroards</h3>
|
||||
<div>
|
||||
<form>
|
||||
<div>
|
||||
|
@ -11,48 +17,41 @@
|
|||
<label for="password">Password:</label>
|
||||
<input type="password" id="password" @bind="Password" />
|
||||
</div>
|
||||
<button type="submit" @onclick="SubmitForm">Submit</button>
|
||||
<button type="submit" href="javascript:void(0)" @onclick="login">Submit</button>
|
||||
</form>
|
||||
|
||||
@if (tried)
|
||||
{
|
||||
@if (verified)
|
||||
{
|
||||
<span>Verifed!</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span>False login</span>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<span>Plz login</span>
|
||||
}
|
||||
|
||||
|
||||
</div>
|
||||
@code {
|
||||
private string Email { get; set; }
|
||||
private string Password { get; set; }
|
||||
|
||||
private bool verified = false;
|
||||
private bool tried = false;
|
||||
private bool verified;
|
||||
|
||||
private async Task SubmitForm()
|
||||
private async Task login()
|
||||
{
|
||||
tried = true;
|
||||
AccountData target = (await AccountsRepository.getAccountsByMailAsync(Email))[0];
|
||||
if (target == null)
|
||||
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, target.Password);
|
||||
verified = BCrypt.Net.BCrypt.Verify(Password, user.Password);
|
||||
if (verified)
|
||||
{
|
||||
verified = true;
|
||||
var customAuthStateProvider = (CustomAuthenticationStateProvider)authStateProvider;
|
||||
await customAuthStateProvider.UpdateAuthenticationStateAsync(user);
|
||||
navManager.NavigateTo("/", true);
|
||||
return;
|
||||
}
|
||||
verified = false;
|
||||
await js.InvokeVoidAsync("alert", $"Wrong creds:\n{BCrypt.Net.BCrypt.HashPassword(Password)}");
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
UserData target = (await UsersRepository.getUserByEmailAsync(Email));
|
||||
|
||||
*/
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue