Added EonaCat.LogStack.Status
Updated EonaCat.LogStack.LogClient to support EonaCat.LogStack.Status
This commit is contained in:
30
EonaCat.LogStack.Status/Pages/Admin/Login.cshtml.cs
Normal file
30
EonaCat.LogStack.Status/Pages/Admin/Login.cshtml.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using EonaCat.LogStack.Status.Services;
|
||||
|
||||
namespace EonaCat.LogStack.Status.Pages.Admin;
|
||||
|
||||
// This file is part of the EonaCat project(s) which is released under the Apache License.
|
||||
// See the LICENSE file or go to https://EonaCat.com/License for full license details.
|
||||
|
||||
public class LoginModel : PageModel
|
||||
{
|
||||
private readonly AuthenticationService _auth;
|
||||
public LoginModel(AuthenticationService auth) => _auth = auth;
|
||||
|
||||
[BindProperty] public string Password { get; set; } = "";
|
||||
public string? Error { get; set; }
|
||||
|
||||
public void OnGet() { }
|
||||
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(Password) && await _auth.ValidatePasswordAsync(Password))
|
||||
{
|
||||
HttpContext.Session.SetString("IsAdmin", "true");
|
||||
return RedirectToPage("/Index");
|
||||
}
|
||||
Error = "Invalid password.";
|
||||
return Page();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user