diff --git a/Controllers/HomeController.cs b/Controllers/HomeController.cs index 60e4e13..76459ec 100644 --- a/Controllers/HomeController.cs +++ b/Controllers/HomeController.cs @@ -219,6 +219,13 @@ namespace CarCareTracker.Controllers var userName = User.Identity.Name; return PartialView("_AccountModal", new UserData() { EmailAddress = emailAddress, UserName = userName }); } + [Authorize(Roles = nameof(UserData.IsRootUser))] + [HttpGet] + public IActionResult GetRootAccountInformationModal() + { + var userName = User.Identity.Name; + return PartialView("_RootAccountModal", new UserData() { UserName = userName }); + } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() { diff --git a/Controllers/LoginController.cs b/Controllers/LoginController.cs index f2332c7..b4d23e7 100644 --- a/Controllers/LoginController.cs +++ b/Controllers/LoginController.cs @@ -220,7 +220,7 @@ namespace CarCareTracker.Controllers var result = _loginLogic.ResetPasswordByUser(credentials); return Json(result); } - [Authorize] //User must already be logged in to do this. + [Authorize(Roles = nameof(UserData.IsRootUser))] //User must already be logged in as root user to do this. [HttpPost] public IActionResult CreateLoginCreds(LoginModel credentials) { @@ -235,7 +235,7 @@ namespace CarCareTracker.Controllers } return Json(false); } - [Authorize] + [Authorize(Roles = nameof(UserData.IsRootUser))] [HttpPost] public IActionResult DestroyLoginCreds() { diff --git a/Views/Home/Index.cshtml b/Views/Home/Index.cshtml index 61bf67c..ef095fe 100644 --- a/Views/Home/Index.cshtml +++ b/Views/Home/Index.cshtml @@ -41,7 +41,12 @@ @translator.Translate(userLanguage,"Admin Panel") } - @if (!User.IsInRole(nameof(UserData.IsRootUser))) + @if (User.IsInRole(nameof(UserData.IsRootUser))) + { +