feat: improved login and register, improved sidebar
Signed-off-by: limited_dev <loginakkisativ@gmail.com>
This commit is contained in:
parent
a6d395ab58
commit
3a6ffaec46
11 changed files with 147 additions and 97 deletions
|
@ -9,27 +9,16 @@
|
|||
<h3 class="headLogin">Login to bulletbroards</h3>
|
||||
<div class="login">
|
||||
<form>
|
||||
<RadzenTemplateForm TItem="Model" Data="model" Submit=@login>
|
||||
<RadzenStack Gap="1rem" Class="gapeing">
|
||||
<RadzenFormField Text="Email" Variant="@vari">
|
||||
<ChildContent>
|
||||
<RadzenTextBox Name="Email" @bind-Value=@model.Email />
|
||||
</ChildContent>
|
||||
<Helper>
|
||||
<RadzenRequiredValidator Component="Email" Text="First name is required." />
|
||||
</Helper>
|
||||
</RadzenFormField>
|
||||
<RadzenFormField Text="Password" Variant="@vari">
|
||||
<ChildContent>
|
||||
<RadzenTextBox Name="Password" @bind-Value=@model.Password />
|
||||
</ChildContent>
|
||||
<Helper>
|
||||
<RadzenRequiredValidator Component="Password" Text="Your Password" />
|
||||
</Helper>
|
||||
</RadzenFormField>
|
||||
<RadzenButton ButtonType="ButtonType.Submit" Text="Login" ></RadzenButton>
|
||||
</RadzenStack>
|
||||
</RadzenTemplateForm>
|
||||
<RadzenFormField Text="Email" Variant="Variant.Outlined">
|
||||
<RadzenTextBox @bind-Value="@Email" />
|
||||
</RadzenFormField>
|
||||
<br/>
|
||||
<RadzenFormField Text="Password" Variant="Variant.Outlined">
|
||||
<RadzenPassword @bind-Value="@Password" />
|
||||
</RadzenFormField>
|
||||
<br/>
|
||||
<br/>
|
||||
<RadzenButton Click=@login Text="login" ButtonStyle="ButtonStyle.Secondary" />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
@ -38,25 +27,20 @@
|
|||
|
||||
private bool verified;
|
||||
|
||||
class Model
|
||||
{
|
||||
public string Email { get; set; }
|
||||
public string Password { get; set; }
|
||||
}
|
||||
|
||||
Model model = new Model();
|
||||
public string Email { get; set; }
|
||||
public string Password { get; set; }
|
||||
|
||||
private async Task login()
|
||||
{
|
||||
Console.WriteLine("loggin you in...");
|
||||
var user = await UsersRepository.getUserByEmailRawAsync(model.Email);
|
||||
var user = await UsersRepository.getUserByEmailRawAsync(Email);
|
||||
if (user == null)
|
||||
{
|
||||
await js.InvokeVoidAsync("alert", "User does not exist");
|
||||
verified = false;
|
||||
return;
|
||||
}
|
||||
verified = BCrypt.Net.BCrypt.Verify(model.Password, user.Password);
|
||||
verified = BCrypt.Net.BCrypt.Verify(Password, user.Password);
|
||||
if (verified)
|
||||
{
|
||||
verified = true;
|
||||
|
|
|
@ -5,33 +5,38 @@
|
|||
@inject AuthenticationStateProvider authStateProvider
|
||||
@inject NavigationManager navManager
|
||||
|
||||
<h3>Register to bulletbroards</h3>
|
||||
<div>
|
||||
<div class="login">
|
||||
<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>
|
||||
<RadzenFormField Text="Email" Variant="Variant.Outlined">
|
||||
<RadzenTextBox @bind-Value="@Email" />
|
||||
</RadzenFormField>
|
||||
<br/>
|
||||
<RadzenFormField Text="Password" Variant="Variant.Outlined">
|
||||
<RadzenPassword @bind-Value="@Password" />
|
||||
</RadzenFormField>
|
||||
<br/>
|
||||
<RadzenCheckBox @bind-Value=@is18 Name="is_18" />
|
||||
<RadzenLabel Text="I am atleast 18 Years old." Component="is_18" />
|
||||
<br/>
|
||||
<br/>
|
||||
<RadzenButton Click=@login Text="login" ButtonStyle="ButtonStyle.Secondary" />
|
||||
</form>
|
||||
</div>
|
||||
<span>By registering you confirm that you are atleast 18 years of age.</span>
|
||||
|
||||
|
||||
|
||||
|
||||
@code {
|
||||
private string Email { get; set; }
|
||||
private string Password { get; set; }
|
||||
private bool is18 { get; set; }
|
||||
|
||||
private string msg { get; set; }
|
||||
|
||||
private bool verified;
|
||||
|
||||
private async Task login()
|
||||
{
|
||||
if (!is18)
|
||||
return;
|
||||
Console.WriteLine("Registering...");
|
||||
UserData userToCreate = new UserData()
|
||||
{
|
||||
|
@ -64,7 +69,4 @@
|
|||
}
|
||||
await js.InvokeVoidAsync("alert", $"Wrong Password");
|
||||
}
|
||||
}
|
||||
@code {
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
.headLogin{
|
||||
text-align: center;
|
||||
-webkit-text-size-adjust: auto;
|
||||
}
|
||||
.login{
|
||||
text-align: center;
|
||||
align-items:center;
|
||||
font-style: unset;}
|
||||
.gaping{
|
||||
alignment: left;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue