diff options
| author | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-05-07 15:46:55 +0300 |
|---|---|---|
| committer | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-05-07 15:46:55 +0300 |
| commit | 756889d2023c584a847b48b498279c702b1adaf0 (patch) | |
| tree | 6dd234957154ede9621af6e464201f642c168434 /ExamTemplate/Web | |
| parent | d066d187f9e3348d56d0752d7a3966fbf5ff88f7 (diff) | |
| download | it-kariera-exam-template-756889d2023c584a847b48b498279c702b1adaf0.tar it-kariera-exam-template-756889d2023c584a847b48b498279c702b1adaf0.tar.gz it-kariera-exam-template-756889d2023c584a847b48b498279c702b1adaf0.zip | |
User now gets logged out only when they change their username
Diffstat (limited to 'ExamTemplate/Web')
| -rw-r--r-- | ExamTemplate/Web/Controllers/UserController.cs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/ExamTemplate/Web/Controllers/UserController.cs b/ExamTemplate/Web/Controllers/UserController.cs index c855c39..4d245f7 100644 --- a/ExamTemplate/Web/Controllers/UserController.cs +++ b/ExamTemplate/Web/Controllers/UserController.cs @@ -112,19 +112,20 @@ namespace ExamTemplate.Web.Controllers if (!this._userService.IsSignedIn(HttpContext.User)) return RedirectToAction("Login"); + UserServiceModel loggedInUser = await this._userService.GetUserByClaimsAsync(HttpContext.User); + EditUserServiceModel editUserServiceModel = this._autoMapper.Map<EditUserServiceModel>(editUserViewModel); bool result = await this._userService.EditUserAsync(HttpContext.User, editUserServiceModel); if (result) { - await this._userService.LogoutAsync(); + if (loggedInUser.Username != editUserViewModel.Username) + await this._userService.LogoutAsync(); + return RedirectToAction("Profile", new { username = editUserViewModel.Username }); } else - { - UserServiceModel userServiceModel = await this._userService.GetUserByClaimsAsync(HttpContext.User); - return RedirectToAction("Profile", new { username = userServiceModel.Username }); - } + return RedirectToAction("Profile", new { username = loggedInUser.Username }); } } } |
