Factoring out Constants.AdminPane and Constants.HostUser
This commit is contained in:
parent
becc779db8
commit
f33fb4d001
|
@ -216,7 +216,7 @@ else
|
|||
private string _username = string.Empty;
|
||||
private string _password = string.Empty;
|
||||
private bool _integratedsecurity = true;
|
||||
private string _hostusername = Constants.HostUser;
|
||||
private string _hostusername = UserNames.Host;
|
||||
private string _hostpassword = string.Empty;
|
||||
|
||||
private string _name = string.Empty;
|
||||
|
@ -311,7 +311,7 @@ else
|
|||
// validate host credentials
|
||||
var user = new User();
|
||||
user.SiteId = PageState.Site.SiteId;
|
||||
user.Username = Constants.HostUser;
|
||||
user.Username = UserNames.Host;
|
||||
user.Password = _hostpassword;
|
||||
user = await UserService.LoginUserAsync(user, false, false);
|
||||
if (user.IsAuthenticated)
|
||||
|
|
|
@ -31,7 +31,7 @@ else
|
|||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
if (PageState.EditMode && UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, PageState.Page.Permissions) && Name != Constants.AdminPane)
|
||||
if (PageState.EditMode && UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, PageState.Page.Permissions) && Name != PaneNames.Admin)
|
||||
{
|
||||
_useadminborder = true;
|
||||
_paneadminborder = "app-pane-admin-border";
|
||||
|
@ -47,7 +47,7 @@ else
|
|||
{
|
||||
if (PageState.ModuleId != -1 && PageState.Action != Constants.DefaultAction)
|
||||
{
|
||||
if (Name.ToLower() == Constants.AdminPane.ToLower())
|
||||
if (Name.ToLower() == PaneNames.Admin.ToLower())
|
||||
{
|
||||
Module module = PageState.Modules.FirstOrDefault(item => item.ModuleId == PageState.ModuleId);
|
||||
if (module != null && !module.IsDeleted)
|
||||
|
|
|
@ -505,7 +505,7 @@
|
|||
// ensure module's pane exists in current page and if not, assign it to the Admin pane
|
||||
if (page.Panes == null || page.Panes.FindIndex(item => item.Equals(module.Pane, StringComparison.OrdinalIgnoreCase)) == -1)
|
||||
{
|
||||
module.Pane = Constants.AdminPane;
|
||||
module.Pane = PaneNames.Admin;
|
||||
}
|
||||
|
||||
// calculate module position within pane
|
||||
|
|
|
@ -118,7 +118,7 @@ namespace Oqtane.Controllers
|
|||
|
||||
bool verified;
|
||||
bool allowregistration;
|
||||
if (user.Username == Constants.HostUser || User.IsInRole(RoleNames.Admin))
|
||||
if (user.Username == UserNames.Host || User.IsInRole(RoleNames.Admin))
|
||||
{
|
||||
verified = true;
|
||||
allowregistration = true;
|
||||
|
@ -164,7 +164,7 @@ namespace Oqtane.Controllers
|
|||
}
|
||||
|
||||
// assign to host role if this is the host user ( initial installation )
|
||||
if (user.Username == Constants.HostUser)
|
||||
if (user.Username == UserNames.Host)
|
||||
{
|
||||
int hostroleid = _roles.GetRoles(user.SiteId, true).Where(item => item.Name == RoleNames.Host).FirstOrDefault().RoleId;
|
||||
UserRole userrole = new UserRole();
|
||||
|
@ -206,7 +206,7 @@ namespace Oqtane.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
if (newUser != null && user.Username != Constants.HostUser)
|
||||
if (newUser != null && user.Username != UserNames.Host)
|
||||
{
|
||||
// add auto assigned roles to user for site
|
||||
List<Role> roles = _roles.GetRoles(user.SiteId).Where(item => item.IsAutoAssigned).ToList();
|
||||
|
|
|
@ -83,7 +83,7 @@ namespace Oqtane.Infrastructure
|
|||
if (!string.IsNullOrEmpty(install.ConnectionString) && !string.IsNullOrEmpty(install.Aliases) && !string.IsNullOrEmpty(install.HostPassword) && !string.IsNullOrEmpty(install.HostEmail))
|
||||
{
|
||||
// silent install
|
||||
install.HostName = Constants.HostUser;
|
||||
install.HostName = UserNames.Host;
|
||||
install.SiteTemplate = GetInstallationConfig(SettingKeys.SiteTemplateKey, Constants.DefaultSiteTemplate);
|
||||
install.DefaultTheme = GetInstallationConfig(SettingKeys.DefaultThemeKey, Constants.DefaultTheme);
|
||||
install.DefaultLayout = GetInstallationConfig(SettingKeys.DefaultLayoutKey, Constants.DefaultLayout);
|
||||
|
@ -439,17 +439,17 @@ namespace Oqtane.Infrastructure
|
|||
};
|
||||
site = sites.AddSite(site);
|
||||
|
||||
IdentityUser identityUser = identityUserManager.FindByNameAsync(Constants.HostUser).GetAwaiter().GetResult();
|
||||
IdentityUser identityUser = identityUserManager.FindByNameAsync(UserNames.Host).GetAwaiter().GetResult();
|
||||
if (identityUser == null)
|
||||
{
|
||||
identityUser = new IdentityUser { UserName = Constants.HostUser, Email = install.HostEmail, EmailConfirmed = true };
|
||||
identityUser = new IdentityUser { UserName = UserNames.Host, Email = install.HostEmail, EmailConfirmed = true };
|
||||
var create = identityUserManager.CreateAsync(identityUser, install.HostPassword).GetAwaiter().GetResult();
|
||||
if (create.Succeeded)
|
||||
{
|
||||
var user = new User
|
||||
{
|
||||
SiteId = site.SiteId,
|
||||
Username = Constants.HostUser,
|
||||
Username = UserNames.Host,
|
||||
Password = install.HostPassword,
|
||||
Email = install.HostEmail,
|
||||
DisplayName = install.HostName,
|
||||
|
|
|
@ -18,7 +18,9 @@ namespace Oqtane.Shared {
|
|||
|
||||
public const string ActionToken = "{Action}";
|
||||
public const string DefaultAction = "Index";
|
||||
public const string AdminPane = "Admin";
|
||||
|
||||
[Obsolete("Use PaneNames.Admin")]
|
||||
public const string AdminPane = PaneNames.Admin;
|
||||
public const string ModuleDelimiter = "*";
|
||||
public const string UrlParametersDelimiter = "!";
|
||||
|
||||
|
@ -35,7 +37,8 @@ namespace Oqtane.Shared {
|
|||
|
||||
public const string ContentUrl = "/api/file/download/";
|
||||
|
||||
public const string HostUser = "host";
|
||||
[Obsolete("Use UserNames.Host instead.")]
|
||||
public const string HostUser = UserNames.Host;
|
||||
|
||||
public const string MasterTenant = "Master";
|
||||
public const string DefaultSite = "Default Site";
|
||||
|
|
9
Oqtane.Shared/Shared/PaneNames.cs
Normal file
9
Oqtane.Shared/Shared/PaneNames.cs
Normal file
|
@ -0,0 +1,9 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Oqtane.Shared {
|
||||
public class PaneNames {
|
||||
public const string Admin = "Admin";
|
||||
}
|
||||
}
|
9
Oqtane.Shared/Shared/UserNames.cs
Normal file
9
Oqtane.Shared/Shared/UserNames.cs
Normal file
|
@ -0,0 +1,9 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Oqtane.Shared {
|
||||
public class UserNames {
|
||||
public const string Host = "host";
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user