user login, register, hashed passwords, announcements start
This commit is contained in:
32
StudentHouseDashboard/WebApp/Pages/Login.cshtml.cs
Normal file
32
StudentHouseDashboard/WebApp/Pages/Login.cshtml.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using StudentHouseDashboard.Models;
|
||||
using StudentHouseDashboard.Managers;
|
||||
|
||||
namespace WebApp.Pages
|
||||
{
|
||||
public class LoginModel : PageModel
|
||||
{
|
||||
[BindProperty]
|
||||
public User MyUser { get; set; }
|
||||
|
||||
public void OnGet()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnPost()
|
||||
{
|
||||
var userManager = new UserManager();
|
||||
|
||||
foreach (var item in userManager.GetAllUsers())
|
||||
{
|
||||
if (item.Name == MyUser.Name && BCrypt.Net.BCrypt.Verify(MyUser.Password, item.Password))
|
||||
{
|
||||
MyUser = item;
|
||||
ViewData["confirm"] = $"Welcome, {MyUser.Name}! {MyUser.Id}, {MyUser.Password}, {MyUser.Role}";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user