Added UserModel, Added Login and Logout and authorization, Made dark mode default

This commit is contained in:
2025-09-29 21:51:32 +02:00
parent 11c37376ad
commit 5c633bd17c
11 changed files with 246 additions and 20 deletions

View File

@@ -0,0 +1,9 @@
@{
ViewData["Title"] = "Access denied";
}
<div class="text-center">
<h1 class="display-4">Access denied</h1>
<p>You currently do not have permission to access the page you tried to access.</p>
<a href="/Home/Login">Please click here to return to the login page</a>
</div>

View File

@@ -0,0 +1,28 @@
@{
ViewData["Title"] = "Login";
}
<div class="text-center">
<h1 class="display-4">Login</h1>
@{
if (Model.ErrorText is not null)
{
<div class="alert alert-danger text-center login-error">
<h2>@Model.ErrorText</h2>
</div>
}
}
<form method="post" action="/Home/Login" class="mt-4" style="max-width: 400px; margin: auto;">
<div class="form-group mb-3">
<label for="username" class="form-label">Username</label>
<input type="text" class="form-control" id="username" name="username" required>
</div>
<div class="form-group mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<button type="submit" class="btn btn-primary w-100">Login</button>
</form>
</div>

View File

@@ -9,9 +9,9 @@
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/Berufsschule_HAM.styles.css" asp-append-version="true" />
</head>
<body>
<body data-bs-theme="dark">
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar bg border-bottom box-shadow mb-3">
<div class="container-fluid">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Berufsschule_HAM</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
@@ -21,10 +21,17 @@
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
<a class="nav-link text" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
@if (User.Identity.IsAuthenticated)
{
<a class="nav-link text" asp-area="" asp-controller="Home" asp-action="Logout">Log out</a>
}
else
{
<a class="nav-link text" asp-area="" asp-controller="Home" asp-action="Login">Login</a>
}
</li>
</ul>
</div>
@@ -39,7 +46,7 @@
<footer class="border-top footer text-muted">
<div class="container">
&copy; 2025 - Berufsschule_HAM - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
&copy; 2025 - Berufsschule_HAM
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script>