Closed
Merge Request #908 · created by Mukul Rajput


Unblockuser rememberme


From unblockuserRememberme into Develop

Closed by Amrita Vishnoi

Changes were not merged into target branch

2 participants



400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js
1 1 'use strict';
2 2  
3   -AIA.controller("HomeController", ["$rootScope", "Modules", "$log", "$location", "$timeout", "DataService", "AuthenticationService", "LoginConstants", "UserModules", "LoginMessageConstants", "AdminService", "$http", "AdminConstants", "UserTypeConstants", "AIAConstants",
4   -function ($rootScope, Modules, $log, $location, $timeout, DataService, AuthenticationService, LoginConstants, UserModules, LoginMessageConstants, AdminService, $http, AdminConstants, UserTypeConstants,AIAConstants) {
  3 +AIA.controller("HomeController", ["$rootScope", "$scope", "Modules", "$log", "$location", "$timeout", "DataService", "AuthenticationService", "LoginConstants", "UserModules", "LoginMessageConstants", "AdminService", "$http", "AdminConstants", "UserTypeConstants", "AIAConstants",
  4 +function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, AuthenticationService, LoginConstants, UserModules, LoginMessageConstants, AdminService, $http, AdminConstants, UserTypeConstants,AIAConstants) {
5 5  
6 6 //$scope.pageToOpen = {
7 7 // name: 'MainMenu'
... ... @@ -42,6 +42,8 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
42 42 $rootScope.current_year = AIAConstants.current_year;
43 43 // on refersh this variable will also get null that is why we are only checking this variable on initialize that if it is null that means page gets refershed.
44 44 $rootScope.refreshcheck = null;
  45 + var isCommingSoonModel = true;
  46 +
45 47 $rootScope.isCloseSettingClicked = false;
46 48  
47 49  
... ... @@ -140,9 +142,26 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
140 142 $rootScope.isVisibleResetPass = true;
141 143 }
142 144 else {
143   - $rootScope.isVisibleLogin = true;
144   - $rootScope.isVisibleResetPass = false;
145   - getUserDetails();
  145 +
  146 + $rootScope.isVisibleLogin = true;
  147 + $rootScope.isVisibleResetPass = false;
  148 +
  149 + //get user is already loggedin or not
  150 + $scope.currentUserDetails = $rootScope.getLocalStorageValue('loggedInUserDetails');
  151 + if ($scope.currentUserDetails != undefined) {
  152 + AuthenticateAlreadyLoggedInUser();
  153 + }
  154 + var isRememberChecked = $rootScope.getLocalStorageValue('isRememberMeChecked');
  155 +
  156 + if ($rootScope.getLocalStorageValue('isRememberMeChecked') != "" && sessionStorage.getItem("loginSession") == null) {
  157 + sessionStorage.setItem("loginSession", "true");
  158 + }
  159 + if (isRememberChecked == "true" && sessionStorage.getItem("loginSession") == "true" && $rootScope.isVisibleLogin == true) {
  160 +
  161 + $timeout(function () {
  162 + $rootScope.userInfo = { username: $rootScope.getLocalStorageValue('RememberMeLoginId'), password: $rootScope.getLocalStorageValue('RememberMePassword'), rememberChk: true };
  163 + }, 800);
  164 + }
146 165 }
147 166 }
148 167  
... ... @@ -158,21 +177,24 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
158 177  
159 178 $rootScope.AuthenticateUser = function (userInfo)
160 179 {
  180 +
  181 +
161 182 if (navigator.cookieEnabled) {
162   -
163 183 $rootScope.errorMessage = "";
164   - if (userInfo.username == "" || userInfo.username == null || userInfo.password == "" || userInfo.password == null) {
  184 + if (userInfo.username == "" || userInfo.username == null || userInfo.username == undefined || userInfo.password == "" || userInfo.password == null || userInfo.password == undefined) {
165 185  
166 186 // alert(LoginMessageConstants.USER_CREDENTIALS_MISSING);
167 187 $rootScope.errorMessage = LoginMessageConstants.USER_CREDENTIALS_MISSING;
168 188 $("#messageModal").modal('show');
169 189 }
170 190 else {
171   -
  191 +
  192 +
172 193 AuthenticationService.authenticateUser(userInfo)
173 194 .then(
174 195  
175 196 function (result) {
  197 +
176 198 if (result == LoginConstants.USER_NOT_FOUND) {
177 199 $rootScope.isVisibleLogin = true;
178 200 // alert(LoginMessageConstants.USER_OR_PASSWORD_INCORRECT);
... ... @@ -180,6 +202,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
180 202 $("#messageModal").modal('show');
181 203 }
182 204 else {
  205 +
183 206 if (typeof result.LoginId != undefined || result.LoginId != "" || result.LoginId != null) {
184 207  
185 208 if ($("#messageModal").length > 0) {
... ... @@ -241,25 +264,76 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
241 264 }
242 265 else {
243 266  
244   - //if (result.UserType == UserTypeConstants.SUPER_ADMIN && result.IsActive) { //(!result.IsSubscriptionExpired) &&
245   - if (result.LicenseId == 0 && result.IsActive) {
246   - $rootScope.userData = result;
247   - $rootScope.userModules = result.Modules;
248   - $rootScope.isVisibleLogin = false;
  267 + //LicenseId would be zero for admin that is why we set the haveRoleAdmin = true
  268 + if (result.LicenseId == 0 && result.IsActive)
  269 + {
249 270 $rootScope.haveRoleAdmin = true;
250   - localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
251   - ShowAssignedModulesPopup(result.Modules);
  271 +
  272 + $rootScope.userData = result;
  273 + $rootScope.userModules = result.Modules;
  274 +
  275 + if ($scope.currentUserDetails == null || $scope.currentUserDetails == undefined || $scope.currentUserDetails == "") {
  276 + localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
  277 + }
  278 +
  279 + if (isCommingSoonModel == true)
  280 + {
  281 +
  282 + ShowAssignedModulesPopup(result.Modules);
  283 +
  284 + if (userInfo.rememberChk) {
  285 +
  286 + $scope.saveRemeberMeDetails(result, userInfo);
  287 + }
  288 +
  289 + sessionStorage.setItem("loginSession", "true");
  290 + localStorage.setItem('isCommingSoonModel', false);
  291 +
  292 + $rootScope.isVisibleLogin = false;
  293 + }
  294 +
  295 +
252 296 $location.path('/');
253 297  
254 298 }
255 299 else {
256   - if (result.LicenseInfo != null && result.LicenseInfo.IsTermAccepted) {
  300 + if (result.LicenseInfo != null && result.LicenseInfo.IsTermAccepted)
  301 + {
  302 + //0.
257 303 $rootScope.userData = result;
258 304 $rootScope.userModules = result.Modules;
259   - $rootScope.isVisibleLogin = false;
  305 +
  306 + //1. set haveRoleAdmin = false because LicenseInfo is not null
260 307 $rootScope.haveRoleAdmin = false;
261   - localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
262   - ShowAssignedModulesPopup(result.Modules);
  308 +
  309 + //2.
  310 + if ($scope.currentUserDetails == null || $scope.currentUserDetails == undefined || $scope.currentUserDetails == "") {
  311 +
  312 + localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
  313 + }
  314 +
  315 + // 3.ShowAssignedModulesPopup
  316 + //isCommingSoonModel =true only when user comes first time on application and login
  317 + if (isCommingSoonModel == true)
  318 + {
  319 +
  320 + ShowAssignedModulesPopup(result.Modules);
  321 + }
  322 +
  323 + //4.
  324 + if($scope.rememberChk)
  325 + {
  326 +
  327 + $scope.saveRemeberMeDetails(result, userInfo);
  328 + }
  329 +
  330 + //5.
  331 + sessionStorage.setItem("loginSession", "true");
  332 + $rootScope.isVisibleLogin = false;
  333 +
  334 + //6. reset the isCommingSoonModel to false in local storage so that upcomming module pop up would not show again to the user after firts time
  335 + localStorage.setItem('isCommingSoonModel', false);
  336 +
263 337 $location.path('/');
264 338  
265 339 }
... ... @@ -275,6 +349,8 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
275 349 $location.path('/');
276 350 }
277 351 }
  352 +
  353 +
278 354  
279 355 }
280 356  
... ... @@ -297,7 +373,15 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
297 373 $rootScope.promptUserForCookies();
298 374 }
299 375  
300   - }
  376 + }
  377 +
  378 + $scope.saveRemeberMeDetails = function (result, userInfo) {
  379 +
  380 + localStorage.setItem('RememberMeLoginId', result.LoginId);
  381 + localStorage.setItem('RememberMePassword', result.Password);
  382 + localStorage.setItem("isRememberMeChecked", userInfo.rememberChk);
  383 + }
  384 +
301 385  
302 386 function ShowAssignedModulesPopup(userModules) {
303 387 var allModules = Modules;
... ... @@ -335,6 +419,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
335 419 $('#dvPendingModules').show();
336 420 }
337 421 }
  422 +
338 423 $rootScope.UpdateLicenseTermStatus = function () {
339 424 $('#dvTermCondition').fadeOut();
340 425 var currentUserDetails = $rootScope.getLocalStorageValue('loggedInUserDetails');
... ... @@ -382,34 +467,54 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
382 467 });
383 468 }
384 469 };
  470 + $rootScope.RememberMe = function (isRememberMeChecked)
  471 + {
  472 + if (localStorage.getItem('isRememberMeChecked') != null)
  473 + {
  474 + localStorage.removeItem('loggedInUserDetails');
  475 + localStorage.removeItem('isRememberMeChecked');
  476 + localStorage.removeItem('RememberMeLoginId');
  477 + localStorage.removeItem('RememberMePassword');
  478 +
  479 + }
  480 +
  481 + }
385 482  
386 483  
387 484 $rootScope.LogoutUser = function () {
388 485 localStorage.removeItem('loggedInUserDetails');
389   - localStorage.clear();
  486 + // localStorage.clear();
390 487 document.location = '/';
391 488 $rootScope.isVisibleLogin = true;
392 489 }
393 490  
394   - function getUserDetails() { //Retain logged in user details
395   - var currentUserDetails = $rootScope.getLocalStorageValue('loggedInUserDetails');
396   - if (currentUserDetails) {
  491 + function AuthenticateAlreadyLoggedInUser()
  492 + {
  493 +
  494 + isCommingSoonModel = $rootScope.getLocalStorageValue('isCommingSoonModel');
  495 +
397 496 try {
398   - var userInfo = JSON.parse(currentUserDetails);
  497 + var userInfo = JSON.parse($scope.currentUserDetails);
399 498  
400 499 if (userInfo.LoginId != undefined || userInfo.LoginId != "" || userInfo.LoginId != null) {
401 500  
402   - if (userInfo.UserType == UserTypeConstants.SUPER_ADMIN && userInfo.IsActive) { //(!result.IsSubscriptionExpired) &&
403   -
404   - $rootScope.userData = userInfo;
405   -
  501 + if (userInfo.UserType == UserTypeConstants.SUPER_ADMIN && userInfo.IsActive) {
  502 +
  503 + //0
  504 + $rootScope.userData = userInfo;
406 505 $rootScope.userModules = userInfo.Modules;
407   -
408   - $rootScope.isVisibleLogin = false;
  506 +
  507 + //1.
  508 + userInfo["username"] = userInfo.LoginId;
  509 + userInfo["password"] = userInfo.Password;
  510 +
  511 + //2.
  512 + $rootScope.AuthenticateUser(userInfo);
  513 +
409 514 $rootScope.haveRoleAdmin = true;
410 515  
411 516 if ($rootScope.refreshcheck == null) {
412   -
  517 +
413 518 if ($location.path() == "/lab-exercises-detail") {
414 519  
415 520 $location.url('/');
... ... @@ -418,7 +523,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
418 523  
419 524 $location.path('/');
420 525 }
421   -
  526 + $rootScope.isVisibleLogin = false;
422 527 }
423 528  
424 529 }
... ... @@ -427,11 +532,12 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
427 532 {
428 533 $rootScope.haveRoleAdmin = false;
429 534  
430   - if (userInfo.LicenseInfo.IsTermAccepted) {
  535 + if (userInfo.LicenseInfo.IsTermAccepted)
  536 + {
431 537 $rootScope.userData = userInfo;
432 538 $rootScope.userModules = userInfo.Modules;
433 539 $rootScope.isVisibleLogin = false;
434   - //$rootScope.haveRoleAdmin = true;
  540 +
435 541  
436 542 if ($rootScope.refreshcheck == null) {
437 543 $location.path('/');
... ... @@ -451,11 +557,12 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
451 557 }
452 558 }
453 559 }
  560 +
454 561 }
455 562 catch (e) {
456 563 localStorage.removeItem('loggedInUserDetails');
457 564 }
458   - }
  565 +
459 566 }
460 567  
461 568 $rootScope.SendMailToUser = function (userInfo, isMailForForgotPassword) {
... ...
400-SOURCECODE/AIAHTML5.Web/index.html
... ... @@ -205,9 +205,12 @@
205 205 <span class="help-block text-right small "><a href="#" class="color-white">Forgot Password?</a></span>-->
206 206 <div class="input-group">
207 207 <span class="input-group-addon"><i class="fa fa-key"></i></span>
208   - <input type="password" class="form-control" placeholder="Password" ng-model="userInfo.password">
  208 + <input type="password" id="UserPassword" class="form-control" placeholder="Password" ng-model="userInfo.password">
209 209 </div>
210 210 <span class="help-block text-right small "><a class="color-white" style="cursor: pointer;" id="forgotPasswordAnchor" data-toggle="modal" ng-click="forgotPwdModalShow();" data-target=".forgot-sm1">Forgot Password?</a></span> <!--#resetpass" href="/app/views/Home/resetPwd.html"-->
  211 + <div class="checkbox">
  212 + <label style="font-size: 85%;color:#fff !important;"><input type="checkbox" ng-model="userInfo.rememberChk" ng-click="RememberMe(this.userInfo.rememberChk)">Remember me</label>
  213 + </div>
211 214 </div>
212 215 <div class="form-group">
213 216 <button class="btn btn-primary pull-right" ng-click="AuthenticateUser(userInfo)">Log In</button>
... ...
400-SOURCECODE/AIAHTML5.Web/themes/default/css/bootstrap/3.3.6/main.css
... ... @@ -1263,4 +1263,9 @@ a[disabled] {
1263 1263 #LabExMinimizedId .fa
1264 1264 {
1265 1265 font-size: 15px;
1266   -}
1267 1266 \ No newline at end of file
  1267 +}
  1268 +
  1269 +#UserPassword
  1270 + {
  1271 + -webkit-text-security: disc;
  1272 + }
1268 1273 \ No newline at end of file
... ...