From d27a8c82abccda877069e5471e41dd09dcb28441 Mon Sep 17 00:00:00 2001 From: Utkarsh Singh Date: Thu, 7 Sep 2017 15:15:50 +0530 Subject: [PATCH] Committing restructured unblock user code --- 400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs | 186 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------ 400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js | 4 ++-- 2 files changed, 98 insertions(+), 92 deletions(-) diff --git a/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs b/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs index ed6822b..1fe62b8 100644 --- a/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs +++ b/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs @@ -198,112 +198,40 @@ namespace AIAHTML5.API.Models objUser.License = null; } - objUser.IncorrectLoginAttemptCount = objModel.GetIncorrectLoginAttempts(objUser.Id); - if (objUser.IncorrectLoginAttemptCount >= 5) - objUser.IsBlocked = true; - - if (objUser.UserType == User.SUPER_ADMIN || objUser.UserType == User.GENERAL_ADMIN) { - objUser.Modules = objModel.GetUserModules(); - } - else - { - if (objUser.License != null) + ArrayList blockedAdminUsersList = objModel.GetBlockedAdminUsers(objUser.UserTypeId); + if (blockedAdminUsersList.Count > 0) { - if (objUser.LicenseSubscriptions != null) + foreach (BlockedUser bUser in blockedAdminUsersList) { - DateTime? subscriptionValidThrough = objUser.LicenseSubscriptions.SubscriptionValidThrough; - if (subscriptionValidThrough != null && subscriptionValidThrough.Value.Date >= DateTime.Now.Date) + DateTime LoginTime = (DateTime)bUser.LoginTime; + DateTime blockTime = LoginTime.AddDays(1); + var difference = DateTime.Compare(DateTime.Now, blockTime); + if (bUser.Id == objUser.Id) { - ArrayList allModulesList = objModel.GetUserModules(); - ArrayList licensedModulesList = objModel.GetModuleStatusByLicenseId(objUser.LicenseId); - - ArrayList userModuleList = objModel.GetUserModulesList(allModulesList, licensedModulesList); - objUser.Modules = userModuleList; - - if (!objUser.License.IsTermAccepted) + if (difference >= 0) { - ArrayList termsList = DBModel.GetTermsOfServiceText(); - foreach (Hashtable item in termsList) - { - objUser.TermsOfServiceTitle = item["title"].ToString(); - objUser.TermsOfServiceText = item["content"].ToString(); - } + objUser.IsBlocked = false; + } + else + { + objUser.IsBlocked = true; } - } - else - { - objUser.IsSubscriptionExpired = true; - objUser.SubscriptionExpirationDateString = objUser.LicenseSubscriptions.SubscriptionValidThrough.Value.Date.ToString("MM/dd/yyyy").ToString(); } } } - } - - if (!string.Equals(objUser.Password, password)) - { - objUser.IsCorrectPassword = false; - objUser.IncorrectLoginAttemptCount = objModel.GetIncorrectLoginAttempts(objUser.Id) + 1; - - objUser.LoginFailureCauseId = ErrorHelper.E_PASSWORD_NOT_MATCH; - - if (objUser.IncorrectLoginAttemptCount == 1) - { - objModel.InsertIncorrectLoginAttempts(objUser.Id); - } else { - if (!objUser.IsBlocked) - objModel.UpdateIncorrectLoginAttempts(objUser.Id); - - if (objUser.IncorrectLoginAttemptCount > 4) - { - objUser.IsBlocked = true; - objUser.LoginFailureCauseId = ErrorHelper.E_USER_ID_BLOCKED_24_HRS; - } + objUser.IsBlocked = false; } - if (objUser.License != null && !string.IsNullOrEmpty(objUser.License.AccountNumber)) - objModel.InsertUserLoginLog(objUser.License.AccountNumber, objUser.LoginFailureCauseId, null, objUser.EditionId.ToString(), null); } else { - if (objUser.License != null) + ArrayList blockedUsersList = objModel.GetBlockedUsers(objUser.UserTypeId, objUser.License.Id); + if (blockedUsersList.Count > 0) { - if (objUser.License.IsActive && !objUser.IsSubscriptionExpired) - { - ArrayList blockedUsersList = objModel.GetBlockedUsers(objUser.UserTypeId, objUser.License.Id); - foreach (BlockedUser bUser in blockedUsersList) - { - DateTime LoginTime = (DateTime)bUser.LoginTime; - DateTime blockTime = LoginTime.AddDays(1); - var difference = DateTime.Compare(DateTime.Now, blockTime); - if (bUser.Id == objUser.Id) - { - if (difference >= 0) - { - objUser.IsBlocked = false; - } - else - { - objUser.IsBlocked = true; - } - } - } - if (!objUser.IsBlocked) - { - objUser.IsCorrectPassword = true; - objModel.InsertLoginDetails(objUser.Id); - objModel.DeleteIncorrectLoginAttempts(objUser.Id); - } - } - else - objUser.IsCorrectPassword = true; - } - else - { - ArrayList blockedAdminUsersList = objModel.GetBlockedAdminUsers(objUser.UserTypeId); - foreach (BlockedUser bUser in blockedAdminUsersList) + foreach (BlockedUser bUser in blockedUsersList) { DateTime LoginTime = (DateTime)bUser.LoginTime; DateTime blockTime = LoginTime.AddDays(1); @@ -320,15 +248,93 @@ namespace AIAHTML5.API.Models } } } - if (!objUser.IsBlocked) + } + else + { + objUser.IsBlocked = false; + } + } + + if (!objUser.IsBlocked) + { + if (!string.Equals(objUser.Password, password)) + { + objUser.IsCorrectPassword = false; + objUser.IncorrectLoginAttemptCount = objModel.GetIncorrectLoginAttempts(objUser.Id) + 1; + + objUser.LoginFailureCauseId = ErrorHelper.E_PASSWORD_NOT_MATCH; + + if (objUser.IncorrectLoginAttemptCount == 1) + { + objModel.InsertIncorrectLoginAttempts(objUser.Id); + } + else + { + if (!objUser.IsBlocked) + objModel.UpdateIncorrectLoginAttempts(objUser.Id); + + if (objUser.IncorrectLoginAttemptCount > 4) + { + objUser.IsBlocked = true; + objUser.LoginFailureCauseId = ErrorHelper.E_USER_ID_BLOCKED_24_HRS; + } + } + if (objUser.License != null && !string.IsNullOrEmpty(objUser.License.AccountNumber)) + { + objModel.InsertUserLoginLog(objUser.License.AccountNumber, objUser.LoginFailureCauseId, null, objUser.EditionId.ToString(), null); + } + } + else + { + if (objUser.UserType == User.SUPER_ADMIN || objUser.UserType == User.GENERAL_ADMIN) { objUser.IsCorrectPassword = true; + objUser.Modules = objModel.GetUserModules(); + objModel.InsertLoginDetails(objUser.Id); objModel.DeleteIncorrectLoginAttempts(objUser.Id); } + else + { + objUser.IsCorrectPassword = true; + + if (objUser.License != null) + { + if (objUser.LicenseSubscriptions != null) + { + DateTime? subscriptionValidThrough = objUser.LicenseSubscriptions.SubscriptionValidThrough; + if (subscriptionValidThrough != null && subscriptionValidThrough.Value.Date >= DateTime.Now.Date) + { + ArrayList allModulesList = objModel.GetUserModules(); + ArrayList licensedModulesList = objModel.GetModuleStatusByLicenseId(objUser.LicenseId); + + ArrayList userModuleList = objModel.GetUserModulesList(allModulesList, licensedModulesList); + objUser.Modules = userModuleList; + + if (!objUser.License.IsTermAccepted) + { + ArrayList termsList = DBModel.GetTermsOfServiceText(); + foreach (Hashtable item in termsList) + { + objUser.TermsOfServiceTitle = item["title"].ToString(); + objUser.TermsOfServiceText = item["content"].ToString(); + } + } + objModel.InsertLoginDetails(objUser.Id); + objModel.DeleteIncorrectLoginAttempts(objUser.Id); + } + else + { + objUser.IsSubscriptionExpired = true; + objUser.SubscriptionExpirationDateString = objUser.LicenseSubscriptions.SubscriptionValidThrough.Value.Date.ToString("MM/dd/yyyy").ToString(); + } + } + } + } } } } + return objUser; } diff --git a/400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js b/400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js index 5bc72c1..76004bf 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js @@ -323,12 +323,12 @@ AIA.constant("LoginMessageConstants", { "NEW_PASSWORD_FIELD_IS_EMPTY": "Please enter new password to reset your password.", "PASSWORD_UPDATE_SUCCESS": "Password updated successfully", "PASSWORD_UPDATE_FAILED": "Password update failed", - "SUBSCRIPTION_EXPIRATION_MESSAGE": "Your license has been expired since ", + "SUBSCRIPTION_EXPIRATION_MESSAGE": "Your license is expired since ", "LICENSE_INACTIVE_MESSAGE": "Your license is inactive.", "INVALID_USER": "Invalid UserID", "USER_INACTIVE_MESSAGE": "User ID is inactive.", "INVALID_PASSWORD": "Invalid Password. UserID and password will be disabled if your password is entered incorrectly for five consecutive attempts. If you have forgotten your password, please click on the forgot password link.", - "USER_BLOCKED": 'Your User ID has been disabled for 24 hours. To unblock please click on "Reset Password" link and select proper option.', + "USER_BLOCKED": 'Your User ID has been disabled for 24 hours. To unblock please click on "Reset Password" link and select "unblock" radio button.', "UNBLOCK_SELECTED": "unblock", "FORGOT_PASSWORD_SELECTED": "forgotpwd", "USER_UNBLOCK_LINK_IN_EMAIL": "Please check you email and unblock your account.", -- libgit2 0.21.4