aboutsummaryrefslogtreecommitdiff
path: root/ExamTemplate
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2021-05-08 18:24:48 +0300
committerSyndamia <kamen.d.mladenov@protonmail.com>2021-05-08 18:24:48 +0300
commitecbfb8cd55ac718f75787817f6fdb833234e6a57 (patch)
tree48d02c5ad3c46118a7a9fb22609988f3eddc4608 /ExamTemplate
parentb06ba4e35c1c1303b72602628be51264f881f05c (diff)
downloadit-kariera-exam-template-ecbfb8cd55ac718f75787817f6fdb833234e6a57.tar
it-kariera-exam-template-ecbfb8cd55ac718f75787817f6fdb833234e6a57.tar.gz
it-kariera-exam-template-ecbfb8cd55ac718f75787817f6fdb833234e6a57.zip
Simplified account edit authorization
Diffstat (limited to 'ExamTemplate')
-rw-r--r--ExamTemplate/Services/UserService.cs7
-rw-r--r--ExamTemplate/Web/Controllers/AccountController.cs3
2 files changed, 0 insertions, 10 deletions
diff --git a/ExamTemplate/Services/UserService.cs b/ExamTemplate/Services/UserService.cs
index e78443a..2f137a1 100644
--- a/ExamTemplate/Services/UserService.cs
+++ b/ExamTemplate/Services/UserService.cs
@@ -81,12 +81,5 @@ namespace ExamTemplate.Services
{
return this._signInManager.IsSignedIn(claimsPrincipal);
}
-
- public async Task<bool> IsAuthorizedToModify(ClaimsPrincipal claimsPrincipal, string username)
- {
- User user = await this._userManager.GetUserAsync(claimsPrincipal);
-
- return user.UserName == username || await this._userManager.IsInRoleAsync(user, "Administrator");
- }
}
}
diff --git a/ExamTemplate/Web/Controllers/AccountController.cs b/ExamTemplate/Web/Controllers/AccountController.cs
index 7fb7ab3..0424070 100644
--- a/ExamTemplate/Web/Controllers/AccountController.cs
+++ b/ExamTemplate/Web/Controllers/AccountController.cs
@@ -106,9 +106,6 @@ namespace ExamTemplate.Web.Controllers
[HttpPost]
public async Task<IActionResult> Edit(EditUserViewModel editUserViewModel)
{
- if (!await this._userService.IsAuthorizedToModify(HttpContext.User, editUserViewModel.OriginalUsername))
- return new UnauthorizedResult();
-
if (!ModelState.IsValid)
return View(editUserViewModel);