Merge remote-tracking branch 'upstream/dev' into ActionDialogSize
This commit is contained in:
commit
f72438996d
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2018-2024 .NET Foundation
|
||||
Copyright (c) 2018-2025 .NET Foundation
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -71,14 +71,14 @@
|
|||
<div class="row mb-1 align-items-center">
|
||||
<Label Class="col-sm-3" For="username" HelpText="Provide a username for the primary user account" ResourceKey="Username">Username:</Label>
|
||||
<div class="col-sm-9">
|
||||
<input id="username" type="text" class="form-control" @bind="@_hostUsername" />
|
||||
<input id="username" type="text" class="form-control" maxlength="256" @bind="@_hostUsername" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-1 align-items-center">
|
||||
<Label Class="col-sm-3" For="password" HelpText="Provide a password for the primary user account" ResourceKey="Password">Password:</Label>
|
||||
<div class="col-sm-9">
|
||||
<div class="input-group">
|
||||
<input id="password" type="@_passwordType" class="form-control" @bind="@_hostPassword" autocomplete="new-password" />
|
||||
<input id="password" type="@_passwordType" class="form-control" maxlength="256" @bind="@_hostPassword" autocomplete="new-password" />
|
||||
<button type="button" class="btn btn-secondary" @onclick="@TogglePassword" tabindex="-1">@_togglePassword</button>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -87,7 +87,7 @@
|
|||
<Label Class="col-sm-3" For="confirm" HelpText="Please confirm the password entered above by entering it again" ResourceKey="Confirm">Confirm:</Label>
|
||||
<div class="col-sm-9">
|
||||
<div class="input-group">
|
||||
<input id="confirm" type="@_confirmPasswordType" class="form-control" @bind="@_confirmPassword" autocomplete="new-password" />
|
||||
<input id="confirm" type="@_confirmPasswordType" class="form-control" maxlength="256" @bind="@_confirmPassword" autocomplete="new-password" />
|
||||
<button type="button" class="btn btn-secondary" @onclick="@ToggleConfirmPassword" tabindex="-1">@_toggleConfirmPassword</button>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -95,7 +95,13 @@
|
|||
<div class="row mb-1 align-items-center">
|
||||
<Label Class="col-sm-3" For="email" HelpText="Provide the email address for the host user account" ResourceKey="Email">Email:</Label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" class="form-control" @bind="@_hostEmail" />
|
||||
<input type="text" class="form-control" maxlength="256" @bind="@_hostEmail" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-1 align-items-center">
|
||||
<Label Class="col-sm-3" For="name" HelpText="Provide the full name of the host user" ResourceKey="Name">Full Name:</Label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" class="form-control" maxlength="50" @bind="@_hostName" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-1 align-items-center">
|
||||
|
@ -153,6 +159,7 @@
|
|||
private string _toggleConfirmPassword = string.Empty;
|
||||
private string _confirmPassword = string.Empty;
|
||||
private string _hostEmail = string.Empty;
|
||||
private string _hostName = string.Empty;
|
||||
private List<SiteTemplate> _templates;
|
||||
private string _template = Constants.DefaultSiteTemplate;
|
||||
private bool _register = true;
|
||||
|
@ -236,7 +243,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
if (connectionString != "" && !string.IsNullOrEmpty(_hostUsername) && !string.IsNullOrEmpty(_hostPassword) && _hostPassword == _confirmPassword && !string.IsNullOrEmpty(_hostEmail) && _hostEmail.Contains("@"))
|
||||
if (connectionString != "" && !string.IsNullOrEmpty(_hostUsername) && !string.IsNullOrEmpty(_hostPassword) && _hostPassword == _confirmPassword && !string.IsNullOrEmpty(_hostEmail) && _hostEmail.Contains("@") && !string.IsNullOrEmpty(_hostName))
|
||||
{
|
||||
var result = await UserService.ValidateUserAsync(_hostUsername, _hostEmail, _hostPassword);
|
||||
if (result.Succeeded)
|
||||
|
@ -256,7 +263,7 @@
|
|||
HostUsername = _hostUsername,
|
||||
HostPassword = _hostPassword,
|
||||
HostEmail = _hostEmail,
|
||||
HostName = _hostUsername,
|
||||
HostName = _hostName,
|
||||
TenantName = TenantNames.Master,
|
||||
IsNewTenant = true,
|
||||
SiteName = Constants.DefaultSite,
|
||||
|
|
|
@ -13,71 +13,71 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
<TabStrip>
|
||||
<TabPanel Name="Pages" ResourceKey="Pages" Heading="Pages">
|
||||
@if (!_pages.Where(item => item.IsDeleted).Any())
|
||||
{
|
||||
<br />
|
||||
<p>@Localizer["NoPage.Deleted"]</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<Pager Items="@_pages.Where(item => item.IsDeleted).OrderByDescending(item => item.DeletedOn)" CurrentPage="@_pagePage.ToString()" OnPageChange="OnPageChangePage">
|
||||
<Header>
|
||||
<th style="width: 1px;"> </th>
|
||||
<th style="width: 1px;"> </th>
|
||||
<th>@SharedLocalizer["Name"]</th>
|
||||
<th>@Localizer["DeletedBy"]</th>
|
||||
<th>@Localizer["DeletedOn"]</th>
|
||||
</Header>
|
||||
<Row>
|
||||
<TabStrip>
|
||||
<TabPanel Name="Pages" ResourceKey="Pages" Heading="Pages">
|
||||
@if (!_pages.Where(item => item.IsDeleted).Any())
|
||||
{
|
||||
<br />
|
||||
<p>@Localizer["NoPage.Deleted"]</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<Pager Items="@_pages.Where(item => item.IsDeleted).OrderByDescending(item => item.DeletedOn)" CurrentPage="@_pagePage.ToString()" OnPageChange="OnPageChangePage">
|
||||
<Header>
|
||||
<th style="width: 1px;"> </th>
|
||||
<th style="width: 1px;"> </th>
|
||||
<th>@SharedLocalizer["Path"]</th>
|
||||
<th>@Localizer["DeletedBy"]</th>
|
||||
<th>@Localizer["DeletedOn"]</th>
|
||||
</Header>
|
||||
<Row>
|
||||
<td><button type="button" @onclick="@(() => RestorePage(context))" class="btn btn-success" title="Restore">@Localizer["Restore"]</button></td>
|
||||
<td><ActionDialog Header="Delete Page" Message="@string.Format(Localizer["Confirm.Page.Delete"], context.Name)" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeletePage(context))" ResourceKey="DeletePage" /></td>
|
||||
<td>@context.Name</td>
|
||||
<td>@context.DeletedBy</td>
|
||||
<td>@context.DeletedOn</td>
|
||||
</Row>
|
||||
</Pager>
|
||||
<br />
|
||||
<ActionDialog Header="Remove All Deleted Pages" Message="Are You Sure You Wish To Permanently Remove All Deleted Pages?" Action="Remove All Deleted Pages" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteAllPages())" ResourceKey="DeleteAllPages" />
|
||||
}
|
||||
</TabPanel>
|
||||
<TabPanel Name="Modules" ResourceKey="Modules" Heading="Modules">
|
||||
@if (!_modules.Where(item => item.IsDeleted).Any())
|
||||
{
|
||||
<br />
|
||||
<p>@Localizer["NoModule.Deleted"]</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<Pager Items="@_modules.Where(item => item.IsDeleted).OrderByDescending(item => item.DeletedOn)" CurrentPage="@_pageModule.ToString()" OnPageChange="OnPageChangeModule">
|
||||
<Header>
|
||||
<th style="width: 1px;"> </th>
|
||||
<th style="width: 1px;"> </th>
|
||||
<th>@Localizer["Page"]</th>
|
||||
<th>@Localizer["Module"]</th>
|
||||
<th>@Localizer["DeletedBy"]</th>
|
||||
<th>@Localizer["DeletedOn"]</th>
|
||||
</Header>
|
||||
<Row>
|
||||
<td><button type="button" @onclick="@(() => RestoreModule(context))" class="btn btn-success" title="Restore">@Localizer["Restore"]</button></td>
|
||||
<td><ActionDialog Header="Delete Module" Message="@string.Format(Localizer["Confirm.Module.Delete"], context.Title)" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteModule(context))" ResourceKey="DeleteModule" /></td>
|
||||
<td>@_pages.Find(item => item.PageId == context.PageId).Name</td>
|
||||
<td>@context.Title</td>
|
||||
<td>@context.DeletedBy</td>
|
||||
<td>@context.DeletedOn</td>
|
||||
</Row>
|
||||
</Pager>
|
||||
<br />
|
||||
<ActionDialog Header="Remove All Deleted Modules" Message="Are You Sure You Wish To Permanently Remove All Deleted Modules?" Action="Remove All Deleted Modules" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteAllModules())" ResourceKey="DeleteAllModules" />
|
||||
}
|
||||
</TabPanel>
|
||||
</TabStrip>
|
||||
<td><ActionDialog Header="Delete Page" Message="@string.Format(Localizer["Confirm.Page.Delete"], context.Name)" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeletePage(context))" ResourceKey="DeletePage" /></td>
|
||||
<td>@context.Path</td>
|
||||
<td>@context.DeletedBy</td>
|
||||
<td>@context.DeletedOn</td>
|
||||
</Row>
|
||||
</Pager>
|
||||
<br />
|
||||
<ActionDialog Header="Remove All Deleted Pages" Message="Are You Sure You Wish To Permanently Remove All Deleted Pages?" Action="Remove All Deleted Pages" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteAllPages())" ResourceKey="DeleteAllPages" />
|
||||
}
|
||||
</TabPanel>
|
||||
<TabPanel Name="Modules" ResourceKey="Modules" Heading="Modules">
|
||||
@if (!_modules.Where(item => item.IsDeleted).Any())
|
||||
{
|
||||
<br />
|
||||
<p>@Localizer["NoModule.Deleted"]</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<Pager Items="@_modules.Where(item => item.IsDeleted).OrderByDescending(item => item.DeletedOn)" CurrentPage="@_pageModule.ToString()" OnPageChange="OnPageChangeModule">
|
||||
<Header>
|
||||
<th style="width: 1px;"> </th>
|
||||
<th style="width: 1px;"> </th>
|
||||
<th>@Localizer["Page"]</th>
|
||||
<th>@Localizer["Module"]</th>
|
||||
<th>@Localizer["DeletedBy"]</th>
|
||||
<th>@Localizer["DeletedOn"]</th>
|
||||
</Header>
|
||||
<Row>
|
||||
<td><button type="button" @onclick="@(() => RestoreModule(context))" class="btn btn-success" title="Restore">@Localizer["Restore"]</button></td>
|
||||
<td><ActionDialog Header="Delete Module" Message="@string.Format(Localizer["Confirm.Module.Delete"], context.Title)" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteModule(context))" ResourceKey="DeleteModule" /></td>
|
||||
<td>@_pages.Find(item => item.PageId == context.PageId).Name</td>
|
||||
<td>@context.Title</td>
|
||||
<td>@context.DeletedBy</td>
|
||||
<td>@context.DeletedOn</td>
|
||||
</Row>
|
||||
</Pager>
|
||||
<br />
|
||||
<ActionDialog Header="Remove All Deleted Modules" Message="Are You Sure You Wish To Permanently Remove All Deleted Modules?" Action="Remove All Deleted Modules" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteAllModules())" ResourceKey="DeleteAllModules" />
|
||||
}
|
||||
</TabPanel>
|
||||
</TabStrip>
|
||||
}
|
||||
|
||||
@code {
|
||||
private List<Page> _pages;
|
||||
private List<Module> _modules;
|
||||
private List<Page> _pages;
|
||||
private List<Module> _modules;
|
||||
private int _pagePage = 1;
|
||||
private int _pageModule = 1;
|
||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
|
||||
|
@ -105,12 +105,25 @@ else
|
|||
{
|
||||
try
|
||||
{
|
||||
page.IsDeleted = false;
|
||||
await PageService.UpdatePageAsync(page);
|
||||
await logger.LogInformation("Page Restored {Page}", page);
|
||||
await Load();
|
||||
StateHasChanged();
|
||||
NavigationManager.NavigateTo(NavigateUrl());
|
||||
var validated = true;
|
||||
if (page.ParentId != null)
|
||||
{
|
||||
var parent = _pages.Find(item => item.PageId == page.ParentId);
|
||||
validated = !parent.IsDeleted;
|
||||
}
|
||||
if (validated)
|
||||
{
|
||||
page.IsDeleted = false;
|
||||
await PageService.UpdatePageAsync(page);
|
||||
await logger.LogInformation("Page Restored {Page}", page);
|
||||
AddModuleMessage(Localizer["Success.Page.Restore"], MessageType.Success);
|
||||
await Load();
|
||||
StateHasChanged();
|
||||
}
|
||||
else
|
||||
{
|
||||
AddModuleMessage(Localizer["Message.Page.Restore"], MessageType.Warning);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -125,9 +138,9 @@ else
|
|||
{
|
||||
await PageService.DeletePageAsync(page.PageId);
|
||||
await logger.LogInformation("Page Permanently Deleted {Page}", page);
|
||||
AddModuleMessage(Localizer["Success.Page.Delete"], MessageType.Success);
|
||||
await Load();
|
||||
StateHasChanged();
|
||||
NavigationManager.NavigateTo(NavigateUrl());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -148,10 +161,10 @@ else
|
|||
}
|
||||
|
||||
await logger.LogInformation("Pages Permanently Deleted");
|
||||
AddModuleMessage(Localizer["Success.Pages.Delete"], MessageType.Success);
|
||||
await Load();
|
||||
HideProgressIndicator();
|
||||
StateHasChanged();
|
||||
NavigationManager.NavigateTo(NavigateUrl());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -169,6 +182,7 @@ else
|
|||
pagemodule.IsDeleted = false;
|
||||
await PageModuleService.UpdatePageModuleAsync(pagemodule);
|
||||
await logger.LogInformation("Module Restored {Module}", module);
|
||||
AddModuleMessage(Localizer["Success.Module.Restore"], MessageType.Success);
|
||||
await Load();
|
||||
StateHasChanged();
|
||||
}
|
||||
|
@ -185,6 +199,7 @@ else
|
|||
{
|
||||
await PageModuleService.DeletePageModuleAsync(module.PageModuleId);
|
||||
await logger.LogInformation("Module Permanently Deleted {Module}", module);
|
||||
AddModuleMessage(Localizer["Success.Module.Delete"], MessageType.Success);
|
||||
await Load();
|
||||
StateHasChanged();
|
||||
}
|
||||
|
@ -205,6 +220,7 @@ else
|
|||
await PageModuleService.DeletePageModuleAsync(module.PageModuleId);
|
||||
}
|
||||
await logger.LogInformation("Modules Permanently Deleted");
|
||||
AddModuleMessage(Localizer["Success.Modules.Delete"], MessageType.Success);
|
||||
await Load();
|
||||
HideProgressIndicator();
|
||||
StateHasChanged();
|
||||
|
|
|
@ -58,7 +58,7 @@ else
|
|||
<td>@context.EffectiveDate</td>
|
||||
<td>@context.ExpiryDate</td>
|
||||
<td>
|
||||
<ActionDialog Header="Remove User" Message="@string.Format(Localizer["Confirm.User.DeleteRole"], context.User.DisplayName)" Action="Delete" Security="SecurityAccessLevel.Edit" Class="btn btn-danger" OnClick="@(async () => await DeleteUserRole(context.UserRoleId))" Disabled="@(context.Role.IsAutoAssigned || context.User.Username == UserNames.Host || context.User.UserId == PageState.User.UserId)" ResourceKey="DeleteUserRole" />
|
||||
<ActionDialog Header="Remove User" Message="@string.Format(Localizer["Confirm.User.DeleteRole"], context.User.DisplayName)" Action="Delete" Security="SecurityAccessLevel.Edit" Class="btn btn-danger" OnClick="@(async () => await DeleteUserRole(context.UserRoleId))" Disabled="@(context.User.Username == UserNames.Host || context.User.UserId == PageState.User.UserId)" ResourceKey="DeleteUserRole" />
|
||||
</td>
|
||||
</Row>
|
||||
</Pager>
|
||||
|
@ -180,27 +180,28 @@ else
|
|||
|
||||
private async Task DeleteUserRole(int UserRoleId)
|
||||
{
|
||||
validated = true;
|
||||
var interop = new Interop(JSRuntime);
|
||||
if (await interop.FormValid(form))
|
||||
try
|
||||
{
|
||||
try
|
||||
var userrole = await UserRoleService.GetUserRoleAsync(UserRoleId);
|
||||
if (userrole.Role.Name == RoleNames.Registered)
|
||||
{
|
||||
userrole.ExpiryDate = DateTime.UtcNow;
|
||||
await UserRoleService.UpdateUserRoleAsync(userrole);
|
||||
await logger.LogInformation("User {Username} Expired From Role {Role}", userrole.User.Username, userrole.Role.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
await UserRoleService.DeleteUserRoleAsync(UserRoleId);
|
||||
await logger.LogInformation("User Removed From Role {UserRoleId}", UserRoleId);
|
||||
AddModuleMessage(Localizer["Confirm.User.RoleRemoved"], MessageType.Success);
|
||||
await GetUserRoles();
|
||||
StateHasChanged();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Removing User From Role {UserRoleId} {Error}", UserRoleId, ex.Message);
|
||||
AddModuleMessage(Localizer["Error.User.RemoveRole"], MessageType.Error);
|
||||
await logger.LogInformation("User {Username} Removed From Role {Role}", userrole.User.Username, userrole.Role.Name);
|
||||
}
|
||||
AddModuleMessage(Localizer["Confirm.User.RoleRemoved"], MessageType.Success);
|
||||
await GetUserRoles();
|
||||
StateHasChanged();
|
||||
}
|
||||
else
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning);
|
||||
await logger.LogError(ex, "Error Removing User From Role {UserRoleId} {Error}", UserRoleId, ex.Message);
|
||||
AddModuleMessage(Localizer["Error.User.RemoveRole"], MessageType.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,15 +51,18 @@
|
|||
<input id="displayname" class="form-control" @bind="@displayname" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-1 align-items-center">
|
||||
<Label Class="col-sm-3" For="isdeleted" HelpText="Indicate if the user is active" ResourceKey="IsDeleted"></Label>
|
||||
<div class="col-sm-9">
|
||||
<select id="isdeleted" class="form-select" @bind="@isdeleted">
|
||||
<option value="True">@SharedLocalizer["Yes"]</option>
|
||||
<option value="False">@SharedLocalizer["No"]</option>
|
||||
</select>
|
||||
@if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
|
||||
{
|
||||
<div class="row mb-1 align-items-center">
|
||||
<Label Class="col-sm-3" For="isdeleted" HelpText="Indicate if the user is active" ResourceKey="IsDeleted"></Label>
|
||||
<div class="col-sm-9">
|
||||
<select id="isdeleted" class="form-select" @bind="@isdeleted">
|
||||
<option value="True">@SharedLocalizer["Yes"]</option>
|
||||
<option value="False">@SharedLocalizer["No"]</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
<div class="row mb-1 align-items-center">
|
||||
<Label Class="col-sm-3" For="lastlogin" HelpText="The date and time when the user last signed in" ResourceKey="LastLogin"></Label>
|
||||
<div class="col-sm-9">
|
||||
|
@ -127,8 +130,11 @@
|
|||
|
||||
<button type="button" class="btn btn-success" @onclick="SaveUser">@SharedLocalizer["Save"]</button>
|
||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
|
||||
<br />
|
||||
<br />
|
||||
@if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host) && isdeleted == "True")
|
||||
{
|
||||
<ActionDialog Header="Delete User" Message="Are You Sure You Wish To Permanently Delete This User?" Action="Delete" Security="SecurityAccessLevel.Host" Class="btn btn-danger" OnClick="@(async () => await DeleteUser())" ResourceKey="DeleteUser" />
|
||||
}
|
||||
<br /><br />
|
||||
<AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon" DeletedBy="@deletedby" DeletedOn="@deletedon"></AuditInfo>
|
||||
}
|
||||
|
||||
|
@ -226,8 +232,10 @@
|
|||
user.Password = _password;
|
||||
user.Email = email;
|
||||
user.DisplayName = string.IsNullOrWhiteSpace(displayname) ? username : displayname;
|
||||
|
||||
user.IsDeleted = (isdeleted == null ? true : Boolean.Parse(isdeleted));
|
||||
if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
|
||||
{
|
||||
user.IsDeleted = (isdeleted == null ? true : Boolean.Parse(isdeleted));
|
||||
}
|
||||
|
||||
user = await UserService.UpdateUserAsync(user);
|
||||
if (user != null)
|
||||
|
@ -259,6 +267,25 @@
|
|||
}
|
||||
}
|
||||
|
||||
private async Task DeleteUser()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host) && userid != PageState.User.UserId)
|
||||
{
|
||||
var user = await UserService.GetUserAsync(userid, PageState.Site.SiteId);
|
||||
await UserService.DeleteUserAsync(user.UserId, PageState.Site.SiteId);
|
||||
await logger.LogInformation("User Permanently Deleted {User}", user);
|
||||
NavigationManager.NavigateTo(NavigateUrl());
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Permanently Deleting User {UserId} {Error}", userid, ex.Message);
|
||||
AddModuleMessage(Localizer["Error.DeleteUser"], MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private bool ValidateProfiles()
|
||||
{
|
||||
foreach (Profile profile in profiles)
|
||||
|
|
|
@ -35,7 +35,7 @@ else
|
|||
<ActionLink Action="Edit" Text="Edit" Parameters="@($"id=" + context.UserId.ToString())" Security="SecurityAccessLevel.Edit" ResourceKey="EditUser" />
|
||||
</td>
|
||||
<td>
|
||||
<ActionDialog Header="Delete User" Message="@string.Format(Localizer["Confirm.User.Delete"], context.User.DisplayName)" Action="Delete" Security="SecurityAccessLevel.Edit" Class="btn btn-danger" OnClick="@(async () => await DeleteUser(context))" Disabled="@(context.UserId == PageState.User.UserId)" ResourceKey="DeleteUser" />
|
||||
<ActionDialog Header="Delete User" Message="@string.Format(Localizer["Confirm.User.Delete"], context.User.DisplayName)" Action="Delete" Security="SecurityAccessLevel.Edit" Class="btn btn-danger" OnClick="@(async () => await DeleteUser(context))" Disabled="@(context.UserId == PageState.User.UserId || context.User.IsDeleted)" ResourceKey="DeleteUser" />
|
||||
</td>
|
||||
<td>
|
||||
<ActionLink Action="Roles" Text="Roles" Parameters="@($"id=" + context.UserId.ToString())" Security="SecurityAccessLevel.Edit" ResourceKey="Roles" />
|
||||
|
@ -611,19 +611,31 @@ else
|
|||
{
|
||||
try
|
||||
{
|
||||
var user = await UserService.GetUserAsync(UserRole.UserId, PageState.Site.SiteId);
|
||||
if (user != null)
|
||||
if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
|
||||
{
|
||||
await UserService.DeleteUserAsync(user.UserId, PageState.Site.SiteId);
|
||||
await logger.LogInformation("User Deleted {User}", UserRole.User);
|
||||
await LoadUsersAsync(true);
|
||||
StateHasChanged();
|
||||
var user = await UserService.GetUserAsync(UserRole.UserId, PageState.Site.SiteId);
|
||||
if (user != null)
|
||||
{
|
||||
user.IsDeleted = true;
|
||||
await UserService.UpdateUserAsync(user);
|
||||
await logger.LogInformation("User Soft Deleted {User}", user);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var userrole = await UserRoleService.GetUserRoleAsync(UserRole.UserRoleId);
|
||||
userrole.ExpiryDate = DateTime.UtcNow;
|
||||
await UserRoleService.UpdateUserRoleAsync(userrole);
|
||||
await logger.LogInformation("User {Username} Expired From Role {Role}", userrole.User.Username, userrole.Role.Name);
|
||||
}
|
||||
AddModuleMessage(Localizer["Success.DeleteUser"], MessageType.Success);
|
||||
await LoadUsersAsync(true);
|
||||
StateHasChanged();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await logger.LogError(ex, "Error Deleting User {User} {Error}", UserRole.User, ex.Message);
|
||||
AddModuleMessage(ex.Message, MessageType.Error);
|
||||
AddModuleMessage(Localizer["Error.DeleteUser"], MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,17 +53,17 @@ else
|
|||
<p align="center">
|
||||
<Pager Items="@userroles">
|
||||
<Header>
|
||||
<th>@Localizer["Roles"]</th>
|
||||
<th>@Localizer["Effective"]</th>
|
||||
<th>@Localizer["Expiry"]</th>
|
||||
<th> </th>
|
||||
<th>@Localizer["Roles"]</th>
|
||||
<th>@Localizer["Effective"]</th>
|
||||
<th>@Localizer["Expiry"]</th>
|
||||
<th> </th>
|
||||
</Header>
|
||||
<Row>
|
||||
<td>@context.Role.Name</td>
|
||||
<td>@Utilities.UtcAsLocalDate(context.EffectiveDate)</td>
|
||||
<td>@Utilities.UtcAsLocalDate(context.ExpiryDate)</td>
|
||||
<td>
|
||||
<ActionDialog Header="Remove Role" Message="@string.Format(Localizer["Confirm.User.RemoveRole"], context.Role.Name)" Action="Delete" Security="SecurityAccessLevel.Edit" Class="btn btn-danger" OnClick="@(async () => await DeleteUserRole(context.UserRoleId))" Disabled="@(context.Role.IsAutoAssigned || (context.Role.Name == RoleNames.Host && userid == PageState.User.UserId))" ResourceKey="DeleteUserRole" />
|
||||
<ActionDialog Header="Remove Role" Message="@string.Format(Localizer["Confirm.User.RemoveRole"], context.Role.Name)" Action="Delete" Security="SecurityAccessLevel.Edit" Class="btn btn-danger" OnClick="@(async () => await DeleteUserRole(context.UserRoleId))" Disabled="@(context.Role.Name == RoleNames.Host && userid == PageState.User.UserId)" ResourceKey="DeleteUserRole" />
|
||||
</td>
|
||||
</Row>
|
||||
</Pager>
|
||||
|
@ -171,8 +171,18 @@ else
|
|||
{
|
||||
try
|
||||
{
|
||||
await UserRoleService.DeleteUserRoleAsync(UserRoleId);
|
||||
await logger.LogInformation("User Removed From Role {UserRoleId}", UserRoleId);
|
||||
var userrole = await UserRoleService.GetUserRoleAsync(UserRoleId);
|
||||
if (userrole.Role.Name == RoleNames.Registered)
|
||||
{
|
||||
userrole.ExpiryDate = DateTime.UtcNow;
|
||||
await UserRoleService.UpdateUserRoleAsync(userrole);
|
||||
await logger.LogInformation("User {Username} Expired From Role {Role}", userrole.User.Username, userrole.Role.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
await UserRoleService.DeleteUserRoleAsync(UserRoleId);
|
||||
await logger.LogInformation("User {Username} Removed From Role {Role}", userrole.User.Username, userrole.Role.Name);
|
||||
}
|
||||
AddModuleMessage(Localizer["Success.User.Remove"], MessageType.Success);
|
||||
await GetUserRoles();
|
||||
StateHasChanged();
|
||||
|
|
|
@ -186,4 +186,10 @@
|
|||
<data name="Message.Username.Invalid" xml:space="preserve">
|
||||
<value>The Username Provided Does Not Meet The System Requirement, It Can Only Contains Letters Or Digits.</value>
|
||||
</data>
|
||||
<data name="Name.Text" xml:space="preserve">
|
||||
<value>Full Name:</value>
|
||||
</data>
|
||||
<data name="Name.HelpText" xml:space="preserve">
|
||||
<value>Provide the full name of the host user</value>
|
||||
</data>
|
||||
</root>
|
|
@ -195,4 +195,25 @@
|
|||
<data name="Modules.Heading" xml:space="preserve">
|
||||
<value>Modules</value>
|
||||
</data>
|
||||
<data name="Message.Page.Restore" xml:space="preserve">
|
||||
<value>You Cannot Restore A Page If Its Parent Is Deleted</value>
|
||||
</data>
|
||||
<data name="Success.Page.Restore" xml:space="preserve">
|
||||
<value>Page Restored Successfully</value>
|
||||
</data>
|
||||
<data name="Success.Page.Delete" xml:space="preserve">
|
||||
<value>Page Deleted Successfully</value>
|
||||
</data>
|
||||
<data name="Success.Pages.Deleted" xml:space="preserve">
|
||||
<value>All Pages Deleted Successfully</value>
|
||||
</data>
|
||||
<data name="Success.Module.Restore" xml:space="preserve">
|
||||
<value>Module Restored Successfully</value>
|
||||
</data>
|
||||
<data name="Success.Module.Delete" xml:space="preserve">
|
||||
<value>Module Deleted Successfully</value>
|
||||
</data>
|
||||
<data name="Success.Modules.Delete" xml:space="preserve">
|
||||
<value>All Modules Deleted Successfully</value>
|
||||
</data>
|
||||
</root>
|
|
@ -195,4 +195,13 @@
|
|||
<data name="LastLogin.Text" xml:space="preserve">
|
||||
<value>Last Login:</value>
|
||||
</data>
|
||||
<data name="DeleteUser.Header" xml:space="preserve">
|
||||
<value>Delete User</value>
|
||||
</data>
|
||||
<data name="DeleteUser.Text" xml:space="preserve">
|
||||
<value>Delete</value>
|
||||
</data>
|
||||
<data name="DeleteUser.Message" xml:space="preserve">
|
||||
<value>Are You Sure You Wish To Permanently Delete This User?</value>
|
||||
</data>
|
||||
</root>
|
|
@ -501,4 +501,10 @@
|
|||
<data name="SaveTokens.HelpText" xml:space="preserve">
|
||||
<value>Specify whether access and refresh tokens should be saved after a successful login. The default is false to reduce the size of the authentication cookie.</value>
|
||||
</data>
|
||||
<data name="Success.DeleteUser" xml:space="preserve">
|
||||
<value>User Deleted Successfully</value>
|
||||
</data>
|
||||
<data name="Error.DeleteUser" xml:space="preserve">
|
||||
<value>Error Deleting User</value>
|
||||
</data>
|
||||
</root>
|
|
@ -427,7 +427,7 @@
|
|||
<value>At Least One Uppercase Letter</value>
|
||||
</data>
|
||||
<data name="Password.ValidationCriteria" xml:space="preserve">
|
||||
<value>Passwords Must Have A Minimum Length Of {0} Characters, Including At Least {1} Unique Character(s), {2}{3}{4}{5} To Satisfy Password Compexity Requirements For This Site.</value>
|
||||
<value>Passwords Must Have A Minimum Length Of {0} Characters, Including At Least {1} Unique Character(s), {2}{3}{4}{5} To Satisfy Password Complexity Requirements For This Site.</value>
|
||||
</data>
|
||||
<data name="ProfileInvalid" xml:space="preserve">
|
||||
<value>{0} Is Not Valid</value>
|
||||
|
@ -474,4 +474,7 @@
|
|||
<data name="User" xml:space="preserve">
|
||||
<value>User</value>
|
||||
</data>
|
||||
<data name="Path" xml:space="preserve">
|
||||
<value>Path</value>
|
||||
</data>
|
||||
</root>
|
|
@ -56,10 +56,5 @@ namespace Oqtane.Services
|
|||
{
|
||||
await PostAsync($"{ApiUrl}/restart");
|
||||
}
|
||||
|
||||
public async Task RegisterAsync(string email)
|
||||
{
|
||||
await PostJsonAsync($"{ApiUrl}/register?email={WebUtility.UrlEncode(email)}", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,13 +34,5 @@ namespace Oqtane.Services
|
|||
/// </summary>
|
||||
/// <returns>internal status/message object</returns>
|
||||
Task RestartAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Registers a new <see cref="User"/>
|
||||
/// </summary>
|
||||
/// <param name="email">Email of the user to be registered</param>
|
||||
/// <returns></returns>
|
||||
Task RegisterAsync(string email);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -174,7 +174,7 @@
|
|||
// get jwt token for downstream APIs
|
||||
if (Context.User.Identity.IsAuthenticated)
|
||||
{
|
||||
CreateJwtToken(alias);
|
||||
GetJwtToken(alias);
|
||||
}
|
||||
|
||||
// includes resources
|
||||
|
@ -441,13 +441,23 @@
|
|||
}
|
||||
}
|
||||
|
||||
private void CreateJwtToken(Alias alias)
|
||||
private void GetJwtToken(Alias alias)
|
||||
{
|
||||
var sitesettings = Context.GetSiteSettings();
|
||||
var secret = sitesettings.GetValue("JwtOptions:Secret", "");
|
||||
if (!string.IsNullOrEmpty(secret))
|
||||
_authorizationToken = Context.Request.Headers[HeaderNames.Authorization];
|
||||
if (!string.IsNullOrEmpty(_authorizationToken))
|
||||
{
|
||||
_authorizationToken = JwtManager.GenerateToken(alias, (ClaimsIdentity)Context.User.Identity, secret, sitesettings.GetValue("JwtOptions:Issuer", ""), sitesettings.GetValue("JwtOptions:Audience", ""), int.Parse(sitesettings.GetValue("JwtOptions:Lifetime", "20")));
|
||||
// bearer token was provided by remote Identity Provider and was persisted using SaveTokens
|
||||
_authorizationToken = _authorizationToken.Replace("Bearer ", "");
|
||||
}
|
||||
else
|
||||
{
|
||||
// generate bearer token if a secret has been configured in User Settings
|
||||
var sitesettings = Context.GetSiteSettings();
|
||||
var secret = sitesettings.GetValue("JwtOptions:Secret", "");
|
||||
if (!string.IsNullOrEmpty(secret))
|
||||
{
|
||||
_authorizationToken = JwtManager.GenerateToken(alias, (ClaimsIdentity)Context.User.Identity, secret, sitesettings.GetValue("JwtOptions:Issuer", ""), sitesettings.GetValue("JwtOptions:Audience", ""), int.Parse(sitesettings.GetValue("JwtOptions:Lifetime", "20")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -60,9 +60,9 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
installation = _databaseManager.Install(config);
|
||||
|
||||
if (installation.Success && config.Register)
|
||||
if (installation.Success)
|
||||
{
|
||||
await RegisterContact(config.HostEmail);
|
||||
await RegisterContact(config.HostEmail, config.HostName, config.Register);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -257,7 +257,7 @@ namespace Oqtane.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
private async Task RegisterContact(string email)
|
||||
private async Task RegisterContact(string email, string name, bool register)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -268,7 +268,7 @@ namespace Oqtane.Controllers
|
|||
{
|
||||
client.DefaultRequestHeaders.Add("Referer", HttpContext.Request.Scheme + "://" + HttpContext.Request.Host.Value);
|
||||
client.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(Constants.PackageId, Constants.Version));
|
||||
var response = await client.GetAsync(new Uri(url + $"/api/registry/contact/?id={_configManager.GetInstallationId()}&email={WebUtility.UrlEncode(email)}")).ConfigureAwait(false);
|
||||
var response = await client.GetAsync(new Uri(url + $"/api/registry/contact/?id={_configManager.GetInstallationId()}&email={WebUtility.UrlEncode(email)}&name={WebUtility.UrlEncode(name)}®ister={register.ToString().ToLower()}")).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -278,14 +278,6 @@ namespace Oqtane.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
// GET api/<controller>/register?email=x
|
||||
[HttpPost("register")]
|
||||
[Authorize(Roles = RoleNames.Host)]
|
||||
public async Task Register(string email)
|
||||
{
|
||||
await RegisterContact(email);
|
||||
}
|
||||
|
||||
public struct ClientAssembly
|
||||
{
|
||||
public ClientAssembly(string filepath, bool hashfilename)
|
||||
|
|
|
@ -9,6 +9,8 @@ using System.Net;
|
|||
using Oqtane.Enums;
|
||||
using Oqtane.Infrastructure;
|
||||
using Oqtane.Repository;
|
||||
using System.Xml.Linq;
|
||||
using Microsoft.AspNetCore.Diagnostics;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
|
@ -279,18 +281,14 @@ namespace Oqtane.Controllers
|
|||
// get current page permissions
|
||||
var currentPermissions = _permissionRepository.GetPermissions(page.SiteId, EntityNames.Page, page.PageId).ToList();
|
||||
|
||||
page = _pages.UpdatePage(page);
|
||||
// preserve new path and deleted status
|
||||
var newPath = page.Path;
|
||||
var deleted = page.IsDeleted;
|
||||
page.Path = currentPage.Path;
|
||||
page.IsDeleted = currentPage.IsDeleted;
|
||||
|
||||
// save url mapping if page path changed
|
||||
if (currentPage.Path != page.Path)
|
||||
{
|
||||
var urlMapping = _urlMappings.GetUrlMapping(page.SiteId, currentPage.Path);
|
||||
if (urlMapping != null)
|
||||
{
|
||||
urlMapping.MappedUrl = page.Path;
|
||||
_urlMappings.UpdateUrlMapping(urlMapping);
|
||||
}
|
||||
}
|
||||
// update page
|
||||
UpdatePage(page, page.Path, newPath, deleted);
|
||||
|
||||
// get differences between current and new page permissions
|
||||
var added = GetPermissionsDifferences(page.PermissionList, currentPermissions);
|
||||
|
@ -320,6 +318,7 @@ namespace Oqtane.Controllers
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
// permissions removed
|
||||
foreach (Permission permission in removed)
|
||||
{
|
||||
|
@ -343,7 +342,6 @@ namespace Oqtane.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
_syncManager.AddSyncEvent(_alias, EntityNames.Page, page.PageId, SyncEventActions.Update);
|
||||
_syncManager.AddSyncEvent(_alias, EntityNames.Site, page.SiteId, SyncEventActions.Refresh);
|
||||
|
||||
// personalized page
|
||||
|
@ -378,6 +376,39 @@ namespace Oqtane.Controllers
|
|||
return page;
|
||||
}
|
||||
|
||||
private void UpdatePage(Page page, string oldPath, string newPath, bool deleted)
|
||||
{
|
||||
var update = false;
|
||||
if (oldPath != newPath)
|
||||
{
|
||||
var urlMapping = _urlMappings.GetUrlMapping(page.SiteId, page.Path);
|
||||
if (urlMapping != null)
|
||||
{
|
||||
urlMapping.MappedUrl = newPath + page.Path.Substring(oldPath.Length);
|
||||
_urlMappings.UpdateUrlMapping(urlMapping);
|
||||
}
|
||||
|
||||
page.Path = newPath + page.Path.Substring(oldPath.Length);
|
||||
update = true;
|
||||
}
|
||||
if (deleted != page.IsDeleted)
|
||||
{
|
||||
page.IsDeleted = deleted;
|
||||
update = true;
|
||||
}
|
||||
if (update)
|
||||
{
|
||||
_pages.UpdatePage(page);
|
||||
_syncManager.AddSyncEvent(_alias, EntityNames.Page, page.PageId, SyncEventActions.Update);
|
||||
}
|
||||
|
||||
// update any children
|
||||
foreach (var _page in _pages.GetPages(page.SiteId).Where(item => item.ParentId == page.PageId))
|
||||
{
|
||||
UpdatePage(_page, oldPath, newPath, deleted);
|
||||
}
|
||||
}
|
||||
|
||||
private List<Permission> GetPermissionsDifferences(List<Permission> permissions1, List<Permission> permissions2)
|
||||
{
|
||||
var differences = new List<Permission>();
|
||||
|
|
|
@ -217,7 +217,7 @@ namespace Oqtane.Controllers
|
|||
|
||||
// DELETE api/<controller>/5?siteid=x
|
||||
[HttpDelete("{id}")]
|
||||
[Authorize(Policy = $"{EntityNames.User}:{PermissionNames.Write}:{RoleNames.Admin}")]
|
||||
[Authorize(Policy = $"{EntityNames.User}:{PermissionNames.Write}:{RoleNames.Host}")]
|
||||
public async Task Delete(int id, string siteid)
|
||||
{
|
||||
User user = _users.GetUser(id, false);
|
||||
|
|
|
@ -524,11 +524,6 @@ namespace Oqtane.Extensions
|
|||
// manage user
|
||||
if (user != null)
|
||||
{
|
||||
// update user
|
||||
user.LastLoginOn = DateTime.UtcNow;
|
||||
user.LastIPAddress = httpContext.Connection.RemoteIpAddress.ToString();
|
||||
_users.UpdateUser(user);
|
||||
|
||||
// manage roles
|
||||
var _userRoles = httpContext.RequestServices.GetRequiredService<IUserRoleRepository>();
|
||||
var userRoles = _userRoles.GetUserRoles(user.UserId, user.SiteId).ToList();
|
||||
|
@ -588,64 +583,78 @@ namespace Oqtane.Extensions
|
|||
}
|
||||
}
|
||||
|
||||
// create claims identity
|
||||
identityuser = await _identityUserManager.FindByNameAsync(user.Username);
|
||||
user.SecurityStamp = identityuser.SecurityStamp;
|
||||
identity = UserSecurity.CreateClaimsIdentity(alias, user, userRoles);
|
||||
identity.Label = ExternalLoginStatus.Success;
|
||||
|
||||
// user profile claims
|
||||
if (!string.IsNullOrEmpty(httpContext.GetSiteSettings().GetValue("ExternalLogin:ProfileClaimTypes", "")))
|
||||
var userrole = userRoles.FirstOrDefault(item => item.Role.Name == RoleNames.Registered);
|
||||
if (!user.IsDeleted && userrole != null && Utilities.IsEffectiveAndNotExpired(userrole.EffectiveDate, userrole.ExpiryDate))
|
||||
{
|
||||
var _settings = httpContext.RequestServices.GetRequiredService<ISettingRepository>();
|
||||
var _profiles = httpContext.RequestServices.GetRequiredService<IProfileRepository>();
|
||||
var profiles = _profiles.GetProfiles(alias.SiteId).ToList();
|
||||
foreach (var mapping in httpContext.GetSiteSettings().GetValue("ExternalLogin:ProfileClaimTypes", "").Split(',', StringSplitOptions.RemoveEmptyEntries))
|
||||
// update user
|
||||
user.LastLoginOn = DateTime.UtcNow;
|
||||
user.LastIPAddress = httpContext.Connection.RemoteIpAddress.ToString();
|
||||
_users.UpdateUser(user);
|
||||
|
||||
// create claims identity
|
||||
identityuser = await _identityUserManager.FindByNameAsync(user.Username);
|
||||
user.SecurityStamp = identityuser.SecurityStamp;
|
||||
identity = UserSecurity.CreateClaimsIdentity(alias, user, userRoles);
|
||||
identity.Label = ExternalLoginStatus.Success;
|
||||
|
||||
// user profile claims
|
||||
if (!string.IsNullOrEmpty(httpContext.GetSiteSettings().GetValue("ExternalLogin:ProfileClaimTypes", "")))
|
||||
{
|
||||
if (mapping.Contains(":"))
|
||||
var _settings = httpContext.RequestServices.GetRequiredService<ISettingRepository>();
|
||||
var _profiles = httpContext.RequestServices.GetRequiredService<IProfileRepository>();
|
||||
var profiles = _profiles.GetProfiles(alias.SiteId).ToList();
|
||||
foreach (var mapping in httpContext.GetSiteSettings().GetValue("ExternalLogin:ProfileClaimTypes", "").Split(',', StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
var claim = claimsPrincipal.Claims.FirstOrDefault(item => item.Type == mapping.Split(":")[0]);
|
||||
if (claim != null)
|
||||
if (mapping.Contains(":"))
|
||||
{
|
||||
var profile = profiles.FirstOrDefault(item => item.Name == mapping.Split(":")[1]);
|
||||
if (profile != null)
|
||||
var claim = claimsPrincipal.Claims.FirstOrDefault(item => item.Type == mapping.Split(":")[0]);
|
||||
if (claim != null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(claim.Value))
|
||||
var profile = profiles.FirstOrDefault(item => item.Name == mapping.Split(":")[1]);
|
||||
if (profile != null)
|
||||
{
|
||||
var setting = _settings.GetSetting(EntityNames.User, user.UserId, profile.Name);
|
||||
if (setting != null)
|
||||
if (!string.IsNullOrEmpty(claim.Value))
|
||||
{
|
||||
setting.SettingValue = claim.Value;
|
||||
_settings.UpdateSetting(setting);
|
||||
}
|
||||
else
|
||||
{
|
||||
setting = new Setting { EntityName = EntityNames.User, EntityId = user.UserId, SettingName = profile.Name, SettingValue = claim.Value, IsPrivate = profile.IsPrivate };
|
||||
_settings.AddSetting(setting);
|
||||
var setting = _settings.GetSetting(EntityNames.User, user.UserId, profile.Name);
|
||||
if (setting != null)
|
||||
{
|
||||
setting.SettingValue = claim.Value;
|
||||
_settings.UpdateSetting(setting);
|
||||
}
|
||||
else
|
||||
{
|
||||
setting = new Setting { EntityName = EntityNames.User, EntityId = user.UserId, SettingName = profile.Name, SettingValue = claim.Value, IsPrivate = profile.IsPrivate };
|
||||
_settings.AddSetting(setting);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, "ExternalLogin", Enums.LogFunction.Security, "The User Profile {ProfileName} Does Not Exist For The Site. Please Verify Your User Profile Definitions.", mapping.Split(":")[1]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, "ExternalLogin", Enums.LogFunction.Security, "The User Profile {ProfileName} Does Not Exist For The Site. Please Verify Your User Profile Definitions.", mapping.Split(":")[1]);
|
||||
_logger.Log(LogLevel.Error, "ExternalLogin", Enums.LogFunction.Security, "The User Profile Claim {ClaimType} Does Not Exist. Please Use The Review Claims Feature To View The Claims Returned By Your Provider.", mapping.Split(":")[0]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, "ExternalLogin", Enums.LogFunction.Security, "The User Profile Claim {ClaimType} Does Not Exist. Please Use The Review Claims Feature To View The Claims Returned By Your Provider.", mapping.Split(":")[0]);
|
||||
_logger.Log(LogLevel.Error, "ExternalLogin", Enums.LogFunction.Security, "The User Profile Claim Mapping {Mapping} Is Not Specified Correctly. It Should Be In The Format 'ClaimType:ProfileName'.", mapping);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Error, "ExternalLogin", Enums.LogFunction.Security, "The User Profile Claim Mapping {Mapping} Is Not Specified Correctly. It Should Be In The Format 'ClaimType:ProfileName'.", mapping);
|
||||
}
|
||||
}
|
||||
|
||||
var _syncManager = httpContext.RequestServices.GetRequiredService<ISyncManager>();
|
||||
_syncManager.AddSyncEvent(alias, EntityNames.User, user.UserId, "Login");
|
||||
|
||||
_logger.Log(LogLevel.Information, "ExternalLogin", Enums.LogFunction.Security, "External User Login Successful For {Username} From IP Address {IPAddress} Using Provider {Provider}", user.Username, httpContext.Connection.RemoteIpAddress.ToString(), providerName);
|
||||
}
|
||||
else
|
||||
{
|
||||
identity.Label = ExternalLoginStatus.AccessDenied;
|
||||
_logger.Log(LogLevel.Error, "ExternalLogin", Enums.LogFunction.Security, "External User Login Denied For {Username}. User Account Is Deleted Or Not An Active Member Of Site {SiteId}.", user.Username, user.SiteId);
|
||||
}
|
||||
|
||||
var _syncManager = httpContext.RequestServices.GetRequiredService<ISyncManager>();
|
||||
_syncManager.AddSyncEvent(alias, EntityNames.User, user.UserId, "Login");
|
||||
|
||||
_logger.Log(LogLevel.Information, "ExternalLogin", Enums.LogFunction.Security, "External User Login Successful For {Username} From IP Address {IPAddress} Using Provider {Provider}", user.Username, httpContext.Connection.RemoteIpAddress.ToString(), providerName);
|
||||
}
|
||||
}
|
||||
else // claims invalid
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace Oqtane.SiteTemplates
|
|||
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||
},
|
||||
Content = "<p>Copyright (c) 2018-2024 .NET Foundation</p>" +
|
||||
Content = "<p>Copyright (c) 2018-2025 .NET Foundation</p>" +
|
||||
"<p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p>" +
|
||||
"<p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p>" +
|
||||
"<p>THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>"
|
||||
|
|
|
@ -363,28 +363,36 @@ namespace Oqtane.Managers
|
|||
}
|
||||
else
|
||||
{
|
||||
user = _users.GetUser(identityuser.UserName);
|
||||
if (user != null)
|
||||
if (await _identityUserManager.IsEmailConfirmedAsync(identityuser))
|
||||
{
|
||||
if (await _identityUserManager.IsEmailConfirmedAsync(identityuser))
|
||||
user = GetUser(identityuser.UserName, alias.SiteId);
|
||||
if (user != null)
|
||||
{
|
||||
user.IsAuthenticated = true;
|
||||
user.LastLoginOn = DateTime.UtcNow;
|
||||
user.LastIPAddress = LastIPAddress;
|
||||
_users.UpdateUser(user);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Security, "User Login Successful For {Username} From IP Address {IPAddress}", user.Username, LastIPAddress);
|
||||
|
||||
_syncManager.AddSyncEvent(alias, EntityNames.User, user.UserId, "Login");
|
||||
|
||||
if (setCookie)
|
||||
// ensure user is registered for site
|
||||
if (user.Roles.Contains(RoleNames.Registered))
|
||||
{
|
||||
await _identitySignInManager.SignInAsync(identityuser, isPersistent);
|
||||
user.IsAuthenticated = true;
|
||||
user.LastLoginOn = DateTime.UtcNow;
|
||||
user.LastIPAddress = LastIPAddress;
|
||||
_users.UpdateUser(user);
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Security, "User Login Successful For {Username} From IP Address {IPAddress}", user.Username, LastIPAddress);
|
||||
|
||||
_syncManager.AddSyncEvent(alias, EntityNames.User, user.UserId, "Login");
|
||||
|
||||
if (setCookie)
|
||||
{
|
||||
await _identitySignInManager.SignInAsync(identityuser, isPersistent);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Security, "User {Username} Is Not An Active Member Of Site {SiteId}", user.Username, alias.SiteId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Security, "User Email Address Not Verified {Username}", user.Username);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogLevel.Information, this, LogFunction.Security, "User Email Address Not Verified {Username}", user.Username);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
<ItemGroup>
|
||||
<ModuleTemplateFiles Include="$(ProjectDir)wwwroot\Modules\Templates\**\*.*" />
|
||||
<ThemeTemplateFiles Include="$(ProjectDir)wwwroot\Themes\Templates\**\*.*" />
|
||||
<MySQLFiles Include="$(OutputPath)Oqtane.Database.MySQL.dll;$(OutputPath)Oqtane.Database.MySQL.pdb;$(OutputPath)MySql.EntityFrameworkCore.dll;$(OutputPath)MySql.Data.dll" />
|
||||
<MySQLFiles Include="$(OutputPath)Oqtane.Database.MySQL.dll;$(OutputPath)Oqtane.Database.MySQL.pdb;$(OutputPath)Pomelo.EntityFrameworkCore.MySql.dll;$(OutputPath)MySql.Data.dll" />
|
||||
<PostgreSQLFiles Include="$(OutputPath)Oqtane.Database.PostgreSQL.dll;$(OutputPath)Oqtane.Database.PostgreSQL.pdb;$(OutputPath)EFCore.NamingConventions.dll;$(OutputPath)Npgsql.EntityFrameworkCore.PostgreSQL.dll;$(OutputPath)Npgsql.dll" />
|
||||
<SqliteFiles Include="$(OutputPath)Oqtane.Database.Sqlite.dll;$(OutputPath)Oqtane.Database.Sqlite.pdb;$(OutputPath)Microsoft.EntityFrameworkCore.Sqlite.dll" />
|
||||
<SqlServerFiles Include="$(OutputPath)Oqtane.Database.SqlServer.dll;$(OutputPath)Oqtane.Database.SqlServer.pdb;$(OutputPath)Microsoft.EntityFrameworkCore.SqlServer.dll" />
|
||||
|
|
|
@ -253,12 +253,12 @@ namespace Oqtane.Pages
|
|||
if (download)
|
||||
{
|
||||
_syncManager.AddSyncEvent(_alias, EntityNames.File, file.FileId, "Download");
|
||||
return PhysicalFile(filepath, file.GetMimeType(), downloadName);
|
||||
return PhysicalFile(filepath, MimeUtilities.GetMimeType(downloadName), downloadName);
|
||||
}
|
||||
else
|
||||
{
|
||||
HttpContext.Response.Headers.Append(HeaderNames.ETag, etag);
|
||||
return PhysicalFile(filepath, file.GetMimeType());
|
||||
return PhysicalFile(filepath, MimeUtilities.GetMimeType(downloadName));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@ export function onUpdate() {
|
|||
let key = getKey(script);
|
||||
|
||||
if (enhancedNavigation) {
|
||||
// reload the script if data-reload is "always" or if the script has not been loaded previously and data-reload is "once" or "true"
|
||||
// reload the script if data-reload is "always" or "true"... or if the script has not been loaded previously and data-reload is "once"
|
||||
let dataReload = script.getAttribute('data-reload');
|
||||
if (dataReload === 'always' || (!scriptKeys.has(key) && (dataReload == 'once' || dataReload === 'true'))) {
|
||||
if ((dataReload === 'always' || dataReload === 'true') || (!scriptKeys.has(key) && dataReload == 'once')) {
|
||||
reloadScript(script);
|
||||
}
|
||||
}
|
||||
|
@ -43,17 +43,13 @@ function reloadScript(script) {
|
|||
replaceScript(script);
|
||||
}
|
||||
} catch (error) {
|
||||
if (script.src) {
|
||||
console.error(`Script Reload failed to load external script: ${script.src}`, error);
|
||||
} else {
|
||||
console.error(`Script Reload failed to load inline script: ${script.innerHTML}`, error);
|
||||
}
|
||||
console.error(`Blazor Script Reload failed to load script: ${getKey(script)}`, error);
|
||||
}
|
||||
}
|
||||
|
||||
function isValid(script) {
|
||||
if (script.innerHTML.includes('document.write(')) {
|
||||
console.log(`Script using document.write() not supported by Script Reload: ${script.innerHTML}`);
|
||||
console.log(`Blazor Script Reload does not support scripts using document.write(): ${script.innerHTML}`);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue
Block a user