This commit is contained in:
2022-03-07 12:22:53 +00:00
parent 362aa31e15
commit 7271b54fba
39 changed files with 356 additions and 90 deletions
@@ -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;