From 522fd2a9f5fc58ffe9ce968d1cbc455d34e036a0 Mon Sep 17 00:00:00 2001 From: "DESKTOP-GENO133\\IvanPlex" Date: Wed, 28 Feb 2024 15:46:59 -0700 Subject: [PATCH] Added empty email address for root users. everything should be functional from here on out. --- Controllers/HomeController.cs | 26 +++++++++++++++ Logic/LoginLogic.cs | 3 +- Views/Home/Index.cshtml | 12 +++++++ Views/Home/_AccountModal.cshtml | 35 +++++++++++++++++++ wwwroot/js/garage.js | 59 +++++++++++++++++++++++++++++++++ 5 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 Views/Home/_AccountModal.cshtml diff --git a/Controllers/HomeController.cs b/Controllers/HomeController.cs index 38a1d11..73e3654 100644 --- a/Controllers/HomeController.cs +++ b/Controllers/HomeController.cs @@ -151,6 +151,32 @@ namespace CarCareTracker.Controllers return Json(false); } } + [HttpPost] + public IActionResult UpdateUserAccount(LoginModel userAccount) + { + try + { + var userId = GetUserID(); + if (userId > 0) + { + var result = _loginLogic.UpdateUserDetails(userId, userAccount); + return Json(result); + } + return Json(new OperationResponse { Success = false, Message = StaticHelper.GenericErrorMessage}); + } + catch (Exception ex) + { + _logger.LogError(ex.Message); + return Json(new OperationResponse { Success = false, Message = StaticHelper.GenericErrorMessage }); + } + } + [HttpGet] + public IActionResult GetUserAccountInformationModal() + { + var emailAddress = User.FindFirstValue(ClaimTypes.Email); + var userName = User.Identity.Name; + return PartialView("_AccountModal", new UserData() { EmailAddress = emailAddress, UserName = userName }); + } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() { diff --git a/Logic/LoginLogic.cs b/Logic/LoginLogic.cs index f151f73..d69c7f5 100644 --- a/Logic/LoginLogic.cs +++ b/Logic/LoginLogic.cs @@ -246,7 +246,8 @@ namespace CarCareTracker.Logic Id = -1, UserName = credentials.UserName, IsAdmin = true, - IsRootUser = true + IsRootUser = true, + EmailAddress = string.Empty }; } else diff --git a/Views/Home/Index.cshtml b/Views/Home/Index.cshtml index 7879c72..0cf4a5e 100644 --- a/Views/Home/Index.cshtml +++ b/Views/Home/Index.cshtml @@ -84,6 +84,12 @@ @translator.Translate(userLanguage,"Admin Panel") } + @if (!User.IsInRole(nameof(UserData.IsRootUser))) + { +
  • + +
  • + }
  • @@ -118,6 +124,12 @@ +