prog commit
This commit is contained in:
parent
4aec0f7cf0
commit
e65022fa3b
6 changed files with 124 additions and 2 deletions
58
ImageBoardServerApp/Pages/Login.razor
Normal file
58
ImageBoardServerApp/Pages/Login.razor
Normal file
|
@ -0,0 +1,58 @@
|
|||
@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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue