Factoring out Constants.AdminPane and Constants.HostUser
This commit is contained in:
@ -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,
|
||||
|
Reference in New Issue
Block a user