aboutsummaryrefslogtreecommitdiff
path: root/ExamTemplate
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2021-05-06 22:46:11 +0300
committerSyndamia <kamen.d.mladenov@protonmail.com>2021-05-06 22:46:11 +0300
commitbd2ebdd29e03425a8314a91b64a5943df83b7559 (patch)
treeb5cf413e17bbbea4aeabe6a95cae97fafa4c3053 /ExamTemplate
parent0f96c5c380b27f31d2a129b9f56faa6bf861194b (diff)
downloadit-kariera-exam-template-bd2ebdd29e03425a8314a91b64a5943df83b7559.tar
it-kariera-exam-template-bd2ebdd29e03425a8314a91b64a5943df83b7559.tar.gz
it-kariera-exam-template-bd2ebdd29e03425a8314a91b64a5943df83b7559.zip
Added logout functionality and updated navbar
Diffstat (limited to 'ExamTemplate')
-rw-r--r--ExamTemplate/Services/UserService.cs5
-rw-r--r--ExamTemplate/Web/Controllers/UserController.cs8
-rw-r--r--ExamTemplate/Web/Views/Shared/_Navbar.cshtml4
-rw-r--r--ExamTemplate/Web/wwwroot/css/styles.css6
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;