diff options
| -rw-r--r-- | ExamTemplate/Services/UserService.cs | 5 | ||||
| -rw-r--r-- | ExamTemplate/Web/Controllers/UserController.cs | 8 | ||||
| -rw-r--r-- | ExamTemplate/Web/Views/Shared/_Navbar.cshtml | 4 | ||||
| -rw-r--r-- | ExamTemplate/Web/wwwroot/css/styles.css | 6 |
4 files changed, 22 insertions, 1 deletions
diff --git a/ExamTemplate/Services/UserService.cs b/ExamTemplate/Services/UserService.cs index f8075f5..332dccb 100644 --- a/ExamTemplate/Services/UserService.cs +++ b/ExamTemplate/Services/UserService.cs @@ -38,5 +38,10 @@ namespace ExamTemplate.Services return result.Succeeded;
}
+
+ public async Task LogoutAsync()
+ {
+ await this._signInManager.SignOutAsync();
+ }
}
}
diff --git a/ExamTemplate/Web/Controllers/UserController.cs b/ExamTemplate/Web/Controllers/UserController.cs index f4b6edf..4a22de7 100644 --- a/ExamTemplate/Web/Controllers/UserController.cs +++ b/ExamTemplate/Web/Controllers/UserController.cs @@ -59,5 +59,13 @@ namespace ExamTemplate.Web.Controllers else return View(); } + + [HttpPost] + public async Task<IActionResult> Logout() + { + await this._userService.LogoutAsync(); + + return RedirectToAction("Login"); + } } } diff --git a/ExamTemplate/Web/Views/Shared/_Navbar.cshtml b/ExamTemplate/Web/Views/Shared/_Navbar.cshtml index f60b799..e32b8c5 100644 --- a/ExamTemplate/Web/Views/Shared/_Navbar.cshtml +++ b/ExamTemplate/Web/Views/Shared/_Navbar.cshtml @@ -17,6 +17,10 @@ @if (SignInManager.IsSignedIn(User)) { <a asp-controller="User" asp-action="">@UserManager.GetUserName(User)</a> + + <form asp-controller="User" asp-action="Logout" method="post"> + <input type="submit" value="Logout"> + </form> } else { diff --git a/ExamTemplate/Web/wwwroot/css/styles.css b/ExamTemplate/Web/wwwroot/css/styles.css index 36880f5..e01dcf0 100644 --- a/ExamTemplate/Web/wwwroot/css/styles.css +++ b/ExamTemplate/Web/wwwroot/css/styles.css @@ -87,7 +87,7 @@ form { display: flex; flex-direction: column; - margin-top: 10px; + align-items: center; justify-content: center; max-width: 300px; @@ -95,6 +95,10 @@ form { margin-right: auto; } +.main > div > form { + margin-top: 10px; +} + form > * { width: 100%; box-sizing: border-box; |
