v1.2.4.2
This commit is contained in:
@@ -28,7 +28,8 @@ namespace Saxonite.Net.Core.Web.Admin.Consoles
|
||||
public override SaxDataCacheConsole GetDataCacheConsole(SaxSessionContext sessionContext)
|
||||
{
|
||||
String fn = GetType().Name + ".GetDataCacheConsole";
|
||||
throw new NotSupportedException(fn + " Data Cache Console not supported in Admin app.");
|
||||
//throw new NotSupportedException(fn + " Data Cache Console not supported in Admin app.");
|
||||
return null;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -70,14 +70,21 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
// 'Keep logged in' can be switched off by the application configuration.
|
||||
keepLoggedIn = App.AppConfig.Security.SignIn.KeepLoggedIn.Allowed && keepLoggedIn;
|
||||
|
||||
// Log user in.
|
||||
userAccount.KeepLoggedIn_Admin = keepLoggedIn;
|
||||
userAccount.LastLoginAt = DateTime.Now;
|
||||
userAccount.InvalidLoginCount = 0;
|
||||
userAccount.LastInvalidLoginAt = DateTime.MinValue;
|
||||
if (!AccountMgr.UpdateUserAccount(userAccount, DbUpdateInfo))
|
||||
// Log user in - Admin details stored against System Admin role.
|
||||
SaxUserRole userRole = userRoles.Find(item => item.UserRole == Sax.UserRole.SystemAdmin);
|
||||
if (userRole == null)
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to update account for " + userAccount.EmailAddress + ": " + AccountMgr.ErrorStateMessage);
|
||||
SaLogger.Warn(fn + " System Admin role not found for " + userAccount.EmailAddress);
|
||||
errorMessage = Localiser["security.msg.signin.invalid"];
|
||||
return false;
|
||||
}
|
||||
userRole.KeepLoggedIn = keepLoggedIn;
|
||||
userRole.LastLoginAt = DateTime.Now;
|
||||
userRole.InvalidLoginCount = 0;
|
||||
userRole.LastInvalidLoginAt = DateTime.MinValue;
|
||||
if (!AccountMgr.UpdateUserRole(userRole, DbUpdateInfo))
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to update Admin user role for " + userAccount.EmailAddress + ": " + AccountMgr.ErrorStateMessage);
|
||||
errorMessage = Localiser["security.msg.signin.invalid"];
|
||||
return false;
|
||||
}
|
||||
@@ -87,7 +94,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
OpenUserSession(SessionContext, userAccount, userRoles);
|
||||
|
||||
// Send the 'Keep Logged In' cookie if requested.
|
||||
if (userAccount.KeepLoggedIn_Admin)
|
||||
if (userRole.KeepLoggedIn)
|
||||
SetKeepLoggedInCookie();
|
||||
|
||||
return true;
|
||||
|
||||
@@ -30,7 +30,8 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
public String RegionNameProvince { get; set; }
|
||||
public int UserRoleCount { get; set; }
|
||||
public bool? SystemAdmin { get; set; } = null;
|
||||
public String LastLoginAt { get; set; }
|
||||
public String LastOnlineLoginAt { get; set; }
|
||||
public String LastAdminLoginAt { get; set; }
|
||||
}
|
||||
private class UserData_Full : UserData_List
|
||||
{
|
||||
@@ -50,9 +51,13 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
data.RegionNameProvince = model.GetRegionName(user.RegionIdProvince);
|
||||
data.UserRoleCount = userRoles?.GetUserRolesByStatus(SaStatus.Active).Count ?? 0;
|
||||
data.SystemAdmin = (userRoles != null && userRoles.Exists(item => item.UserRole == Sax.UserRole.SystemAdmin) ? true : (bool?)null);
|
||||
data.LastLoginAt = model.FormatDateTimeForDisplay(user.LastLoginAt);
|
||||
data.LastOnlineLoginAt = model.FormatDateTimeForDisplay(user.LastLoginAt);
|
||||
data.StatusCode = user.StatusCode;
|
||||
data.StatusDesc = user.StatusDesc;
|
||||
// System Admin role.
|
||||
SaxUserRole userRole_SystemAdmin = userRoles.Find(item => item.UserRole == Sax.UserRole.SystemAdmin);
|
||||
if (userRole_SystemAdmin != null)
|
||||
data.LastAdminLoginAt = model.FormatDateTimeForDisplay(userRole_SystemAdmin.LastLoginAt);
|
||||
}
|
||||
private void PopulateUserResponseData(SaxModel_Admin model, UserData_Full data, SaxUserAccount user, List<SaxUserRole> userRoles)
|
||||
{
|
||||
@@ -138,13 +143,14 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
ColumnDfn colUserRoleCount = AccountMgr.GetUserAccountColumnDfn(SaxUserAccount.Column.UserRoleCount);
|
||||
ColumnDfn colSystemAdminUser = AccountMgr.GetUserAccountColumnDfn(SaxUserAccount.Column.SystemAdminUser);
|
||||
ColumnDfn colLastLogin = AccountMgr.GetUserAccountColumnDfn(SaxUserAccount.Column.LastLoginAt);
|
||||
ColumnDfn colAdminLastLogin = AccountMgr.GetUserAccountColumnDfn(SaxUserAccount.Column.LastAdminLoginAt);
|
||||
ColumnDfn colStatus = AccountMgr.GetUserAccountColumnDfn(SaxUserAccount.Column.Status);
|
||||
List<ColumnDfn> columns = new List<ColumnDfn>()
|
||||
{
|
||||
colId, colEmail, colTitle, colFirstName, colLastName,
|
||||
colCountryName, colProvinceName,
|
||||
colUserRoleCount, colSystemAdminUser,
|
||||
colLastLogin, colStatus
|
||||
colLastLogin, colAdminLastLogin, colStatus
|
||||
};
|
||||
|
||||
// Query items.
|
||||
@@ -164,7 +170,8 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
RegionNameProvince = values.GetString(colProvinceName.DataName),
|
||||
UserRoleCount = StringUtil.ToInt(values.GetString(colUserRoleCount.DataName)),
|
||||
SystemAdmin = StringUtil.ToBool(values.GetString(colSystemAdminUser.DataName)),
|
||||
LastLoginAt = model.FormatDateTimeForDisplay(values.GetDateTime(colLastLogin.DataName)),
|
||||
LastOnlineLoginAt = model.FormatDateTimeForDisplay(values.GetDateTime(colLastLogin.DataName)),
|
||||
LastAdminLoginAt = model.FormatDateTimeForDisplay(values.GetDateTime(colAdminLastLogin.DataName)),
|
||||
StatusCode = values.GetString(colStatus.DataName),
|
||||
StatusDesc = SacsSystem.GetStatusDescForCode(values.GetString(colStatus.DataName))
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user