Refinements to auth
This commit is contained in:
@@ -9,7 +9,7 @@ namespace WebApp.Authentication
|
|||||||
{
|
{
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public async Task<IActionResult> CookieLogin()
|
public async Task<IActionResult> CookieLogin(string email, string password)
|
||||||
{
|
{
|
||||||
// Based on: https://www.codeproject.com/articles/Understanding-authentication-in-Blazor-and-ASP-NET
|
// Based on: https://www.codeproject.com/articles/Understanding-authentication-in-Blazor-and-ASP-NET
|
||||||
// TODO: Fix this up
|
// TODO: Fix this up
|
||||||
|
|||||||
@@ -2,10 +2,43 @@
|
|||||||
|
|
||||||
<h3>Login</h3>
|
<h3>Login</h3>
|
||||||
|
|
||||||
<form action="Auth/CookieLogin" method="post">
|
<form action="Auth/CookieLogin" method="post" >
|
||||||
<button type="submit" class="btn btn-primary">Login</button>
|
<button type="submit" class="btn btn-primary">Login</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<form action="Auth/CookieLogout" method="post">
|
<MudText Typo="Typo.h4" GutterBottom="true">Sign In</MudText>
|
||||||
<button type="submit" class="btn btn-primary">Logout</button>
|
|
||||||
</form>
|
@* <MudTextField T="string" Value="@("staff@mudblazor.com")" Label="E-mail" Variant="Variant.Outlined" Class="my-6"></MudTextField> *@
|
||||||
|
|
||||||
|
<MudTextField @bind-Value="@Password" Label="Password" Variant="Variant.Outlined" InputType="@PasswordInput" Adornment="Adornment.End" AdornmentIcon="@PasswordInputIcon" OnAdornmentClick="TogglePasswordVisibility" />
|
||||||
|
|
||||||
|
<div class="d-flex justify-space-between align-center">
|
||||||
|
<MudCheckBox T="bool" Label="Remember me?" Color="Color.Primary" Class="ml-n1 my-3"></MudCheckBox>
|
||||||
|
<MudLink Href="/pages/authentication/forgot-password">Forgot pwd?</MudLink>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<MudButton Variant="Variant.Filled" Color="Color.Primary" Link="/personal/dashboard" Size="Size.Large" FullWidth="true">Sign In</MudButton>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
string Password { get; set; } = "BMWvBPJXZu";
|
||||||
|
|
||||||
|
bool PasswordVisibility;
|
||||||
|
InputType PasswordInput = InputType.Password;
|
||||||
|
string PasswordInputIcon = Icons.Material.Filled.VisibilityOff;
|
||||||
|
|
||||||
|
void TogglePasswordVisibility()
|
||||||
|
{
|
||||||
|
@if (PasswordVisibility)
|
||||||
|
{
|
||||||
|
PasswordVisibility = false;
|
||||||
|
PasswordInputIcon = Icons.Material.Filled.VisibilityOff;
|
||||||
|
PasswordInput = InputType.Password;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PasswordVisibility = true;
|
||||||
|
PasswordInputIcon = Icons.Material.Filled.Visibility;
|
||||||
|
PasswordInput = InputType.Text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
-5
@@ -23,7 +23,7 @@ builder.Services.AddDatabaseDeveloperPageExceptionFilter();
|
|||||||
|
|
||||||
builder.Services.AddScoped<ClipboardService>();
|
builder.Services.AddScoped<ClipboardService>();
|
||||||
|
|
||||||
builder.Services.AddScoped<StateContainer>(); // Server- side
|
builder.Services.AddScoped<StateContainer>(); // Server-side
|
||||||
builder.Services.AddSingleton<StateContainer>();//Client-side
|
builder.Services.AddSingleton<StateContainer>();//Client-side
|
||||||
|
|
||||||
// Add authentication options
|
// Add authentication options
|
||||||
@@ -59,9 +59,7 @@ app.UseAntiforgery();
|
|||||||
app.MapRazorComponents<App>()
|
app.MapRazorComponents<App>()
|
||||||
.AddInteractiveServerRenderMode();
|
.AddInteractiveServerRenderMode();
|
||||||
|
|
||||||
app.UseEndpoints(endpoints =>
|
// Used for AuthController
|
||||||
{
|
app.MapControllerRoute("default", "{controller}/{action}");
|
||||||
endpoints.MapControllerRoute("default", "{controller}/{action}");
|
|
||||||
});
|
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
|
|||||||
Reference in New Issue
Block a user