Commit 74b70f97ee13e5fabaec24ee30e262d17061a2b2

Authored by Mukul Rajput
1 parent 765a47e5

this is functionality of remember me and unblock user

400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js
... ... @@ -151,6 +151,17 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A
151 151 if ($scope.currentUserDetails != undefined) {
152 152 AuthenticateAlreadyLoggedInUser();
153 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 + }
154 165 }
155 166 }
156 167  
... ... @@ -268,9 +279,17 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A
268 279 if (isCommingSoonModel == true)
269 280 {
270 281  
271   - ShowAssignedModulesPopup(result.Modules);
272   - $rootScope.isVisibleLogin = false;
273   - localStorage.setItem('isCommingSoonModel', false);
  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;
274 293 }
275 294  
276 295  
... ... @@ -280,25 +299,41 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A
280 299 else {
281 300 if (result.LicenseInfo != null && result.LicenseInfo.IsTermAccepted)
282 301 {
  302 + //0.
283 303 $rootScope.userData = result;
284 304 $rootScope.userModules = result.Modules;
285 305  
286   - //set haveRoleAdmin = false because LicenseInfo is not null
  306 + //1. set haveRoleAdmin = false because LicenseInfo is not null
287 307 $rootScope.haveRoleAdmin = false;
288 308  
  309 + //2.
289 310 if ($scope.currentUserDetails == null || $scope.currentUserDetails == undefined || $scope.currentUserDetails == "") {
290 311  
291 312 localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
292 313 }
293 314  
294   - if (isCommingSoonModel == true) {
  315 + // 3.ShowAssignedModulesPopup
  316 + //isCommingSoonModel =true only when user comes first time on application and login
  317 + if (isCommingSoonModel == true)
  318 + {
295 319  
296 320 ShowAssignedModulesPopup(result.Modules);
297   - $rootScope.isVisibleLogin = false;
298   - localStorage.setItem('isCommingSoonModel', false);
299 321 }
300 322  
301   -
  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 +
302 337 $location.path('/');
303 338  
304 339 }
... ... @@ -314,6 +349,8 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A
314 349 $location.path('/');
315 350 }
316 351 }
  352 +
  353 +
317 354  
318 355 }
319 356  
... ... @@ -336,7 +373,15 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A
336 373 $rootScope.promptUserForCookies();
337 374 }
338 375  
339   - }
  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 +
340 385  
341 386 function ShowAssignedModulesPopup(userModules) {
342 387 var allModules = Modules;
... ... @@ -374,6 +419,7 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A
374 419 $('#dvPendingModules').show();
375 420 }
376 421 }
  422 +
377 423 $rootScope.UpdateLicenseTermStatus = function () {
378 424 $('#dvTermCondition').fadeOut();
379 425 var currentUserDetails = $rootScope.getLocalStorageValue('loggedInUserDetails');
... ... @@ -421,20 +467,32 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A
421 467 });
422 468 }
423 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 + }
424 482  
425 483  
426 484 $rootScope.LogoutUser = function () {
427 485 localStorage.removeItem('loggedInUserDetails');
428   - localStorage.clear();
  486 + // localStorage.clear();
429 487 document.location = '/';
430 488 $rootScope.isVisibleLogin = true;
431 489 }
432 490  
433 491 function AuthenticateAlreadyLoggedInUser()
434 492 {
435   -
  493 +
436 494 isCommingSoonModel = $rootScope.getLocalStorageValue('isCommingSoonModel');
437   -
  495 +
438 496 try {
439 497 var userInfo = JSON.parse($scope.currentUserDetails);
440 498  
... ... @@ -499,6 +557,7 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A
499 557 }
500 558 }
501 559 }
  560 +
502 561 }
503 562 catch (e) {
504 563 localStorage.removeItem('loggedInUserDetails');
... ...
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
... ...