From bdf36fc49cc992213cf01736c11958a68b6b0178 Mon Sep 17 00:00:00 2001 From: Shaun Walker Date: Fri, 11 Jun 2021 17:07:54 -0400 Subject: [PATCH] bug fixes --- Oqtane.Client/Modules/Admin/Roles/Users.razor | 2 +- Oqtane.Client/Modules/Admin/Users/Edit.razor | 51 ++++++++++--------- Oqtane.Server/Controllers/RoleController.cs | 2 +- 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/Oqtane.Client/Modules/Admin/Roles/Users.razor b/Oqtane.Client/Modules/Admin/Roles/Users.razor index c8049b18..466ff00c 100644 --- a/Oqtane.Client/Modules/Admin/Roles/Users.razor +++ b/Oqtane.Client/Modules/Admin/Roles/Users.razor @@ -67,7 +67,7 @@ else @context.EffectiveDate @context.ExpiryDate - + diff --git a/Oqtane.Client/Modules/Admin/Users/Edit.razor b/Oqtane.Client/Modules/Admin/Users/Edit.razor index 19254613..46769cd4 100644 --- a/Oqtane.Client/Modules/Admin/Users/Edit.razor +++ b/Oqtane.Client/Modules/Admin/Users/Edit.razor @@ -152,33 +152,36 @@ else { try { - profiles = await ProfileService.GetProfilesAsync(PageState.Site.SiteId); - - userid = Int32.Parse(PageState.QueryString["id"]); - var user = await UserService.GetUserAsync(userid, PageState.Site.SiteId); - if (user != null) + // OnParametersSetAsync is called when the edit modal is closed - in which case there is no id parameter + if (PageState.QueryString.ContainsKey("id")) { - username = user.Username; - email = user.Email; - displayname = user.DisplayName; - if (user.PhotoFileId != null) + profiles = await ProfileService.GetProfilesAsync(PageState.Site.SiteId); + userid = Int32.Parse(PageState.QueryString["id"]); + var user = await UserService.GetUserAsync(userid, PageState.Site.SiteId); + if (user != null) { - photofileid = user.PhotoFileId.Value; - photo = await FileService.GetFileAsync(photofileid); + username = user.Username; + email = user.Email; + displayname = user.DisplayName; + if (user.PhotoFileId != null) + { + photofileid = user.PhotoFileId.Value; + photo = await FileService.GetFileAsync(photofileid); + } + else + { + photofileid = -1; + photo = null; + } + settings = await SettingService.GetUserSettingsAsync(user.UserId); + createdby = user.CreatedBy; + createdon = user.CreatedOn; + modifiedby = user.ModifiedBy; + modifiedon = user.ModifiedOn; + deletedby = user.DeletedBy; + deletedon = user.DeletedOn; + isdeleted = user.IsDeleted.ToString(); } - else - { - photofileid = -1; - photo = null; - } - settings = await SettingService.GetUserSettingsAsync(user.UserId); - createdby = user.CreatedBy; - createdon = user.CreatedOn; - modifiedby = user.ModifiedBy; - modifiedon = user.ModifiedOn; - deletedby = user.DeletedBy; - deletedon = user.DeletedOn; - isdeleted = user.IsDeleted.ToString(); } } catch (Exception ex) diff --git a/Oqtane.Server/Controllers/RoleController.cs b/Oqtane.Server/Controllers/RoleController.cs index aa6c6c29..169c9014 100644 --- a/Oqtane.Server/Controllers/RoleController.cs +++ b/Oqtane.Server/Controllers/RoleController.cs @@ -52,7 +52,7 @@ namespace Oqtane.Controllers public Role Get(int id) { var role = _roles.GetRole(id); - if (role != null && role.SiteId == _alias.SiteId) + if (role != null && (role.SiteId == _alias.SiteId || User.IsInRole(RoleNames.Host))) { return role; }