Commit d27a8c82abccda877069e5471e41dd09dcb28441

Authored by Utkarsh Singh
1 parent 801042e3

Committing restructured unblock user code

400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs
... ... @@ -198,112 +198,40 @@ namespace AIAHTML5.API.Models
198 198 objUser.License = null;
199 199 }
200 200  
201   - objUser.IncorrectLoginAttemptCount = objModel.GetIncorrectLoginAttempts(objUser.Id);
202   - if (objUser.IncorrectLoginAttemptCount >= 5)
203   - objUser.IsBlocked = true;
204   -
205   -
206 201 if (objUser.UserType == User.SUPER_ADMIN || objUser.UserType == User.GENERAL_ADMIN)
207 202 {
208   - objUser.Modules = objModel.GetUserModules();
209   - }
210   - else
211   - {
212   - if (objUser.License != null)
  203 + ArrayList blockedAdminUsersList = objModel.GetBlockedAdminUsers(objUser.UserTypeId);
  204 + if (blockedAdminUsersList.Count > 0)
213 205 {
214   - if (objUser.LicenseSubscriptions != null)
  206 + foreach (BlockedUser bUser in blockedAdminUsersList)
215 207 {
216   - DateTime? subscriptionValidThrough = objUser.LicenseSubscriptions.SubscriptionValidThrough;
217   - if (subscriptionValidThrough != null && subscriptionValidThrough.Value.Date >= DateTime.Now.Date)
  208 + DateTime LoginTime = (DateTime)bUser.LoginTime;
  209 + DateTime blockTime = LoginTime.AddDays(1);
  210 + var difference = DateTime.Compare(DateTime.Now, blockTime);
  211 + if (bUser.Id == objUser.Id)
218 212 {
219   - ArrayList allModulesList = objModel.GetUserModules();
220   - ArrayList licensedModulesList = objModel.GetModuleStatusByLicenseId(objUser.LicenseId);
221   -
222   - ArrayList userModuleList = objModel.GetUserModulesList(allModulesList, licensedModulesList);
223   - objUser.Modules = userModuleList;
224   -
225   - if (!objUser.License.IsTermAccepted)
  213 + if (difference >= 0)
226 214 {
227   - ArrayList termsList = DBModel.GetTermsOfServiceText();
228   - foreach (Hashtable item in termsList)
229   - {
230   - objUser.TermsOfServiceTitle = item["title"].ToString();
231   - objUser.TermsOfServiceText = item["content"].ToString();
232   - }
  215 + objUser.IsBlocked = false;
  216 + }
  217 + else
  218 + {
  219 + objUser.IsBlocked = true;
233 220 }
234   - }
235   - else
236   - {
237   - objUser.IsSubscriptionExpired = true;
238   - objUser.SubscriptionExpirationDateString = objUser.LicenseSubscriptions.SubscriptionValidThrough.Value.Date.ToString("MM/dd/yyyy").ToString();
239 221 }
240 222 }
241 223 }
242   - }
243   -
244   - if (!string.Equals(objUser.Password, password))
245   - {
246   - objUser.IsCorrectPassword = false;
247   - objUser.IncorrectLoginAttemptCount = objModel.GetIncorrectLoginAttempts(objUser.Id) + 1;
248   -
249   - objUser.LoginFailureCauseId = ErrorHelper.E_PASSWORD_NOT_MATCH;
250   -
251   - if (objUser.IncorrectLoginAttemptCount == 1)
252   - {
253   - objModel.InsertIncorrectLoginAttempts(objUser.Id);
254   - }
255 224 else
256 225 {
257   - if (!objUser.IsBlocked)
258   - objModel.UpdateIncorrectLoginAttempts(objUser.Id);
259   -
260   - if (objUser.IncorrectLoginAttemptCount > 4)
261   - {
262   - objUser.IsBlocked = true;
263   - objUser.LoginFailureCauseId = ErrorHelper.E_USER_ID_BLOCKED_24_HRS;
264   - }
  226 + objUser.IsBlocked = false;
265 227 }
266   - if (objUser.License != null && !string.IsNullOrEmpty(objUser.License.AccountNumber))
267   - objModel.InsertUserLoginLog(objUser.License.AccountNumber, objUser.LoginFailureCauseId, null, objUser.EditionId.ToString(), null);
268 228 }
269 229 else
270 230 {
271   - if (objUser.License != null)
  231 + ArrayList blockedUsersList = objModel.GetBlockedUsers(objUser.UserTypeId, objUser.License.Id);
  232 + if (blockedUsersList.Count > 0)
272 233 {
273   - if (objUser.License.IsActive && !objUser.IsSubscriptionExpired)
274   - {
275   - ArrayList blockedUsersList = objModel.GetBlockedUsers(objUser.UserTypeId, objUser.License.Id);
276   - foreach (BlockedUser bUser in blockedUsersList)
277   - {
278   - DateTime LoginTime = (DateTime)bUser.LoginTime;
279   - DateTime blockTime = LoginTime.AddDays(1);
280   - var difference = DateTime.Compare(DateTime.Now, blockTime);
281   - if (bUser.Id == objUser.Id)
282   - {
283   - if (difference >= 0)
284   - {
285   - objUser.IsBlocked = false;
286   - }
287   - else
288   - {
289   - objUser.IsBlocked = true;
290   - }
291   - }
292   - }
293   - if (!objUser.IsBlocked)
294   - {
295   - objUser.IsCorrectPassword = true;
296   - objModel.InsertLoginDetails(objUser.Id);
297   - objModel.DeleteIncorrectLoginAttempts(objUser.Id);
298   - }
299   - }
300   - else
301   - objUser.IsCorrectPassword = true;
302   - }
303   - else
304   - {
305   - ArrayList blockedAdminUsersList = objModel.GetBlockedAdminUsers(objUser.UserTypeId);
306   - foreach (BlockedUser bUser in blockedAdminUsersList)
  234 + foreach (BlockedUser bUser in blockedUsersList)
307 235 {
308 236 DateTime LoginTime = (DateTime)bUser.LoginTime;
309 237 DateTime blockTime = LoginTime.AddDays(1);
... ... @@ -320,15 +248,93 @@ namespace AIAHTML5.API.Models
320 248 }
321 249 }
322 250 }
323   - if (!objUser.IsBlocked)
  251 + }
  252 + else
  253 + {
  254 + objUser.IsBlocked = false;
  255 + }
  256 + }
  257 +
  258 + if (!objUser.IsBlocked)
  259 + {
  260 + if (!string.Equals(objUser.Password, password))
  261 + {
  262 + objUser.IsCorrectPassword = false;
  263 + objUser.IncorrectLoginAttemptCount = objModel.GetIncorrectLoginAttempts(objUser.Id) + 1;
  264 +
  265 + objUser.LoginFailureCauseId = ErrorHelper.E_PASSWORD_NOT_MATCH;
  266 +
  267 + if (objUser.IncorrectLoginAttemptCount == 1)
  268 + {
  269 + objModel.InsertIncorrectLoginAttempts(objUser.Id);
  270 + }
  271 + else
  272 + {
  273 + if (!objUser.IsBlocked)
  274 + objModel.UpdateIncorrectLoginAttempts(objUser.Id);
  275 +
  276 + if (objUser.IncorrectLoginAttemptCount > 4)
  277 + {
  278 + objUser.IsBlocked = true;
  279 + objUser.LoginFailureCauseId = ErrorHelper.E_USER_ID_BLOCKED_24_HRS;
  280 + }
  281 + }
  282 + if (objUser.License != null && !string.IsNullOrEmpty(objUser.License.AccountNumber))
  283 + {
  284 + objModel.InsertUserLoginLog(objUser.License.AccountNumber, objUser.LoginFailureCauseId, null, objUser.EditionId.ToString(), null);
  285 + }
  286 + }
  287 + else
  288 + {
  289 + if (objUser.UserType == User.SUPER_ADMIN || objUser.UserType == User.GENERAL_ADMIN)
324 290 {
325 291 objUser.IsCorrectPassword = true;
  292 + objUser.Modules = objModel.GetUserModules();
  293 +
326 294 objModel.InsertLoginDetails(objUser.Id);
327 295 objModel.DeleteIncorrectLoginAttempts(objUser.Id);
328 296 }
  297 + else
  298 + {
  299 + objUser.IsCorrectPassword = true;
  300 +
  301 + if (objUser.License != null)
  302 + {
  303 + if (objUser.LicenseSubscriptions != null)
  304 + {
  305 + DateTime? subscriptionValidThrough = objUser.LicenseSubscriptions.SubscriptionValidThrough;
  306 + if (subscriptionValidThrough != null && subscriptionValidThrough.Value.Date >= DateTime.Now.Date)
  307 + {
  308 + ArrayList allModulesList = objModel.GetUserModules();
  309 + ArrayList licensedModulesList = objModel.GetModuleStatusByLicenseId(objUser.LicenseId);
  310 +
  311 + ArrayList userModuleList = objModel.GetUserModulesList(allModulesList, licensedModulesList);
  312 + objUser.Modules = userModuleList;
  313 +
  314 + if (!objUser.License.IsTermAccepted)
  315 + {
  316 + ArrayList termsList = DBModel.GetTermsOfServiceText();
  317 + foreach (Hashtable item in termsList)
  318 + {
  319 + objUser.TermsOfServiceTitle = item["title"].ToString();
  320 + objUser.TermsOfServiceText = item["content"].ToString();
  321 + }
  322 + }
  323 + objModel.InsertLoginDetails(objUser.Id);
  324 + objModel.DeleteIncorrectLoginAttempts(objUser.Id);
  325 + }
  326 + else
  327 + {
  328 + objUser.IsSubscriptionExpired = true;
  329 + objUser.SubscriptionExpirationDateString = objUser.LicenseSubscriptions.SubscriptionValidThrough.Value.Date.ToString("MM/dd/yyyy").ToString();
  330 + }
  331 + }
  332 + }
  333 + }
329 334 }
330 335 }
331 336 }
  337 +
332 338 return objUser;
333 339 }
334 340  
... ...
400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js
... ... @@ -323,12 +323,12 @@ AIA.constant("LoginMessageConstants", {
323 323 "NEW_PASSWORD_FIELD_IS_EMPTY": "Please enter new password to reset your password.",
324 324 "PASSWORD_UPDATE_SUCCESS": "Password updated successfully",
325 325 "PASSWORD_UPDATE_FAILED": "Password update failed",
326   - "SUBSCRIPTION_EXPIRATION_MESSAGE": "Your license has been expired since ",
  326 + "SUBSCRIPTION_EXPIRATION_MESSAGE": "Your license is expired since ",
327 327 "LICENSE_INACTIVE_MESSAGE": "Your license is inactive.",
328 328 "INVALID_USER": "Invalid UserID",
329 329 "USER_INACTIVE_MESSAGE": "User ID is inactive.",
330 330 "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.",
331   - "USER_BLOCKED": 'Your User ID has been disabled for 24 hours. To unblock please click on "Reset Password" link and select proper option.',
  331 + "USER_BLOCKED": 'Your User ID has been disabled for 24 hours. To unblock please click on "Reset Password" link and select "unblock" radio button.',
332 332 "UNBLOCK_SELECTED": "unblock",
333 333 "FORGOT_PASSWORD_SELECTED": "forgotpwd",
334 334 "USER_UNBLOCK_LINK_IN_EMAIL": "Please check you email and unblock your account.",
... ...