asp.net/winforms login; uml managers, repositories pages edited
This commit is contained in:
12
StudentHouseDashboard/WebApp/Pages/Error/401.cshtml
Normal file
12
StudentHouseDashboard/WebApp/Pages/Error/401.cshtml
Normal file
@@ -0,0 +1,12 @@
|
||||
@page
|
||||
@model WebApp.Pages.Error._401Model
|
||||
@{
|
||||
ViewData["Title"] = "401 Unauthorised";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Error 401 Unauthorised</h1>
|
||||
<img src="http://http.cat/401" />
|
||||
<p>
|
||||
You do not have rights to access this page!
|
||||
</p>
|
||||
</div>
|
12
StudentHouseDashboard/WebApp/Pages/Error/401.cshtml.cs
Normal file
12
StudentHouseDashboard/WebApp/Pages/Error/401.cshtml.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace WebApp.Pages.Error
|
||||
{
|
||||
public class _401Model : PageModel
|
||||
{
|
||||
public void OnGet()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@@ -15,13 +15,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="px-4 py-5 my-5 text-center">
|
||||
<h2 class="display-5 fw-bold">Why choose our solution?</h2>
|
||||
<div class="col-lg-6 mx-auto">
|
||||
<p class="lead mb-4">Student House Dashboard helps tenants organise common household chores even if they don't know each other very well.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="px-4 py-5 my-5 text-center">
|
||||
<h2 class="display-5 fw-bold">Is it difficult to use?</h2>
|
||||
<div class="col-lg-6 mx-auto">
|
||||
|
@@ -1,7 +1,10 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using StudentHouseDashboard.Models;
|
||||
using StudentHouseDashboard.Managers;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace WebApp.Pages
|
||||
{
|
||||
@@ -14,19 +17,33 @@ namespace WebApp.Pages
|
||||
{
|
||||
}
|
||||
|
||||
public void OnPost()
|
||||
public IActionResult OnPost(string? returnUrl)
|
||||
{
|
||||
var userManager = new UserManager();
|
||||
|
||||
foreach (var item in userManager.GetAllUsers())
|
||||
User? user = userManager.AuthenticatedUser(MyUser.Name, MyUser.Password);
|
||||
if (user != null)
|
||||
{
|
||||
if (item.Name == MyUser.Name && BCrypt.Net.BCrypt.Verify(MyUser.Password, item.Password))
|
||||
List<Claim> claims = new List<Claim>();
|
||||
claims.Add(new Claim(ClaimTypes.Name, user.Name));
|
||||
claims.Add(new Claim("id", user.ID.ToString()));
|
||||
claims.Add(new Claim(ClaimTypes.Role, user.Role.ToString()));
|
||||
var claimsIdentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
|
||||
HttpContext.SignInAsync(new ClaimsPrincipal(claimsIdentity));
|
||||
// ViewData["confirm"] = $"Welcome, {MyUser.Name}! {MyUser.ID}, {MyUser.Password}, {MyUser.Role}";
|
||||
if (!String.IsNullOrWhiteSpace(returnUrl) && Url.IsLocalUrl(returnUrl))
|
||||
{
|
||||
MyUser = item;
|
||||
ViewData["confirm"] = $"Welcome, {MyUser.Name}! {MyUser.ID}, {MyUser.Password}, {MyUser.Role}";
|
||||
return Redirect(returnUrl);
|
||||
}
|
||||
else
|
||||
{
|
||||
return RedirectToPage("Announcements");
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
ModelState.AddModelError("InvalidCredentials", "The supplied username and/or password is invalid");
|
||||
return Page();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -23,10 +23,7 @@
|
||||
<a class="nav-link text-dark" asp-area="" asp-page="/Index">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-page="/Privacy">Privacy</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-page="/Contact">Contact</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-page="/Announcements">Announcements</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-page="/Login">Login</a>
|
||||
@@ -44,7 +41,7 @@
|
||||
|
||||
<footer class="border-top footer text-muted">
|
||||
<div class="container">
|
||||
© 2023 - StudentHouseDashboard - <a asp-area="" asp-page="/Privacy">Privacy</a>
|
||||
<p>StudentHouseDashboard © 2023 <a asp-area="" asp-page="/Privacy">Privacy</a> <a asp-area="" asp-page="/Contact">Contact</a></p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
|
Reference in New Issue
Block a user