58 lines
1.3 KiB
Text
58 lines
1.3 KiB
Text
|
@page "/Login"
|
||
|
@using ImageBoardServerApp.Data.Repository
|
||
|
<h3>Login</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>
|
||
|
<button type="submit" @onclick="SubmitForm">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 async Task SubmitForm()
|
||
|
{
|
||
|
tried = true;
|
||
|
AccountData target = (await AccountsRepository.getAccountsByMailAsync(Email))[0];
|
||
|
if (target == null)
|
||
|
{
|
||
|
verified = false;
|
||
|
return;
|
||
|
}
|
||
|
verified = BCrypt.Net.BCrypt.Verify(Password, target.Password);
|
||
|
if (verified)
|
||
|
{
|
||
|
verified = true;
|
||
|
return;
|
||
|
}
|
||
|
verified = false;
|
||
|
}
|
||
|
}
|