diff --git a/Oqtane.Client/Themes/Controls/Theme/ControlPanel.razor b/Oqtane.Client/Themes/Controls/Theme/ControlPanel.razor index e43b2c9f..10643777 100644 --- a/Oqtane.Client/Themes/Controls/Theme/ControlPanel.razor +++ b/Oqtane.Client/Themes/Controls/Theme/ControlPanel.razor @@ -10,6 +10,8 @@ @inject IPageModuleService PageModuleService @inject ILogService logger @inject ISettingService SettingService +@inject IJSRuntime jsRuntime +@inject IServiceProvider ServiceProvider @inject IStringLocalizer Localizer @inject IStringLocalizer SharedLocalizer @@ -109,10 +111,7 @@ } - } - @if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, PageState.Page.PermissionList)) - {
@@ -220,8 +219,15 @@
@((MarkupString)Message) - } -
+
+ } + +
+
+ +
+
+ } @@ -243,6 +249,15 @@ protected string ModuleType { get; private set; } = "new"; protected string ModuleDefinitionName { get; private set; } = "-"; + protected string Title { get; private set; } = ""; + protected string ContainerType { get; private set; } = ""; + protected string Visibility { get; private set; } = "view"; + protected string Message { get; private set; } = ""; + + private string settingCategory = "CP-category"; + private string settingPane = "CP-pane"; + private string _pane = ""; + protected string Category { get => _category; @@ -273,11 +288,6 @@ } } - protected string Title { get; private set; } = ""; - protected string ContainerType { get; private set; } = ""; - protected string Visibility { get; private set; } = "view"; - protected string Message { get; private set; } = ""; - [Parameter] public string ButtonClass { get; set; } = "btn-outline-secondary"; @@ -293,7 +303,6 @@ [Parameter] public bool ShowLanguageSwitcher { get; set; } = true; - protected override async Task OnParametersSetAsync() { _canViewAdminDashboard = CanViewAdminDashboard(); @@ -510,7 +519,7 @@ switch (location) { case "Admin": - // get admin dashboard moduleid + // get admin dashboard moduleid module = PageState.Modules.FirstOrDefault(item => item.ModuleDefinitionName == Constants.AdminDashboardModule); if (module != null) { @@ -613,9 +622,36 @@ } } - private string settingCategory = "CP-category"; - private string settingPane = "CP-pane"; - private string _pane = ""; + // the following code is duplicated from LoginBase + private async Task LogoutUser() + { + await LoggingService.Log(PageState.Alias, PageState.Page.PageId, null, PageState.User?.UserId, GetType().AssemblyQualifiedName, "Logout", LogFunction.Security, LogLevel.Information, null, "User Logout For Username {Username}", PageState.User?.Username); + + Route route = new Route(PageState.Uri.AbsoluteUri, PageState.Alias.Path); + var url = route.PathAndQuery; + + // verify if anonymous users can access page + if (!UserSecurity.IsAuthorized(null, PermissionNames.View, PageState.Page.PermissionList)) + { + url = PageState.Alias.Path; + } + + if (PageState.Runtime == Shared.Runtime.Hybrid) + { + // hybrid apps utilize an interactive logout + await UserService.LogoutUserAsync(PageState.User); + var authstateprovider = (IdentityAuthenticationStateProvider)ServiceProvider.GetService(typeof(IdentityAuthenticationStateProvider)); + authstateprovider.NotifyAuthenticationChanged(); + NavigationManager.NavigateTo(url, true); + } + else + { + // post to the Logout page to complete the logout process + var fields = new { __RequestVerificationToken = SiteState.AntiForgeryToken, returnurl = url }; + var interop = new Interop(jsRuntime); + await interop.SubmitForm(Utilities.TenantUrl(PageState.Alias, "/pages/logout/"), fields); + } + } private async Task LoadSettingsAsync() {