Commit 78f8adde49fdedaf43236cd32e9104954e8654f0

Authored by Amrita Vishnoi
2 parents 3b7a7b9e 74b70f97

Manual Merge against - Merge Request #908

400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js
1 'use strict'; 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 //$scope.pageToOpen = { 6 //$scope.pageToOpen = {
7 // name: 'MainMenu' 7 // name: 'MainMenu'
@@ -42,6 +42,8 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic @@ -42,6 +42,8 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
42 $rootScope.current_year = AIAConstants.current_year; 42 $rootScope.current_year = AIAConstants.current_year;
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. 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 $rootScope.refreshcheck = null; 44 $rootScope.refreshcheck = null;
  45 + var isCommingSoonModel = true;
  46 +
45 $rootScope.isCloseSettingClicked = false; 47 $rootScope.isCloseSettingClicked = false;
46 48
47 49
@@ -140,9 +142,26 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic @@ -140,9 +142,26 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
140 $rootScope.isVisibleResetPass = true; 142 $rootScope.isVisibleResetPass = true;
141 } 143 }
142 else { 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,21 +177,24 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
158 177
159 $rootScope.AuthenticateUser = function (userInfo) 178 $rootScope.AuthenticateUser = function (userInfo)
160 { 179 {
  180 +
  181 +
161 if (navigator.cookieEnabled) { 182 if (navigator.cookieEnabled) {
162 -  
163 $rootScope.errorMessage = ""; 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 // alert(LoginMessageConstants.USER_CREDENTIALS_MISSING); 186 // alert(LoginMessageConstants.USER_CREDENTIALS_MISSING);
167 $rootScope.errorMessage = LoginMessageConstants.USER_CREDENTIALS_MISSING; 187 $rootScope.errorMessage = LoginMessageConstants.USER_CREDENTIALS_MISSING;
168 $("#messageModal").modal('show'); 188 $("#messageModal").modal('show');
169 } 189 }
170 else { 190 else {
171 - 191 +
  192 +
172 AuthenticationService.authenticateUser(userInfo) 193 AuthenticationService.authenticateUser(userInfo)
173 .then( 194 .then(
174 195
175 function (result) { 196 function (result) {
  197 +
176 if (result == LoginConstants.USER_NOT_FOUND) { 198 if (result == LoginConstants.USER_NOT_FOUND) {
177 $rootScope.isVisibleLogin = true; 199 $rootScope.isVisibleLogin = true;
178 // alert(LoginMessageConstants.USER_OR_PASSWORD_INCORRECT); 200 // alert(LoginMessageConstants.USER_OR_PASSWORD_INCORRECT);
@@ -180,6 +202,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic @@ -180,6 +202,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
180 $("#messageModal").modal('show'); 202 $("#messageModal").modal('show');
181 } 203 }
182 else { 204 else {
  205 +
183 if (typeof result.LoginId != undefined || result.LoginId != "" || result.LoginId != null) { 206 if (typeof result.LoginId != undefined || result.LoginId != "" || result.LoginId != null) {
184 207
185 if ($("#messageModal").length > 0) { 208 if ($("#messageModal").length > 0) {
@@ -241,25 +264,76 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic @@ -241,25 +264,76 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
241 } 264 }
242 else { 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 $rootScope.haveRoleAdmin = true; 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 $location.path('/'); 296 $location.path('/');
253 297
254 } 298 }
255 else { 299 else {
256 - if (result.LicenseInfo != null && result.LicenseInfo.IsTermAccepted) { 300 + if (result.LicenseInfo != null && result.LicenseInfo.IsTermAccepted)
  301 + {
  302 + //0.
257 $rootScope.userData = result; 303 $rootScope.userData = result;
258 $rootScope.userModules = result.Modules; 304 $rootScope.userModules = result.Modules;
259 - $rootScope.isVisibleLogin = false; 305 +
  306 + //1. set haveRoleAdmin = false because LicenseInfo is not null
260 $rootScope.haveRoleAdmin = false; 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 $location.path('/'); 337 $location.path('/');
264 338
265 } 339 }
@@ -275,6 +349,8 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic @@ -275,6 +349,8 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
275 $location.path('/'); 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,7 +373,15 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
297 $rootScope.promptUserForCookies(); 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 function ShowAssignedModulesPopup(userModules) { 386 function ShowAssignedModulesPopup(userModules) {
303 var allModules = Modules; 387 var allModules = Modules;
@@ -335,6 +419,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic @@ -335,6 +419,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
335 $('#dvPendingModules').show(); 419 $('#dvPendingModules').show();
336 } 420 }
337 } 421 }
  422 +
338 $rootScope.UpdateLicenseTermStatus = function () { 423 $rootScope.UpdateLicenseTermStatus = function () {
339 $('#dvTermCondition').fadeOut(); 424 $('#dvTermCondition').fadeOut();
340 var currentUserDetails = $rootScope.getLocalStorageValue('loggedInUserDetails'); 425 var currentUserDetails = $rootScope.getLocalStorageValue('loggedInUserDetails');
@@ -382,34 +467,54 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic @@ -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 $rootScope.LogoutUser = function () { 484 $rootScope.LogoutUser = function () {
388 localStorage.removeItem('loggedInUserDetails'); 485 localStorage.removeItem('loggedInUserDetails');
389 - localStorage.clear(); 486 + // localStorage.clear();
390 document.location = '/'; 487 document.location = '/';
391 $rootScope.isVisibleLogin = true; 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 try { 496 try {
398 - var userInfo = JSON.parse(currentUserDetails); 497 + var userInfo = JSON.parse($scope.currentUserDetails);
399 498
400 if (userInfo.LoginId != undefined || userInfo.LoginId != "" || userInfo.LoginId != null) { 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 $rootScope.userModules = userInfo.Modules; 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 $rootScope.haveRoleAdmin = true; 514 $rootScope.haveRoleAdmin = true;
410 515
411 if ($rootScope.refreshcheck == null) { 516 if ($rootScope.refreshcheck == null) {
412 - 517 +
413 if ($location.path() == "/lab-exercises-detail") { 518 if ($location.path() == "/lab-exercises-detail") {
414 519
415 $location.url('/'); 520 $location.url('/');
@@ -418,7 +523,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic @@ -418,7 +523,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
418 523
419 $location.path('/'); 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,11 +532,12 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
427 { 532 {
428 $rootScope.haveRoleAdmin = false; 533 $rootScope.haveRoleAdmin = false;
429 534
430 - if (userInfo.LicenseInfo.IsTermAccepted) { 535 + if (userInfo.LicenseInfo.IsTermAccepted)
  536 + {
431 $rootScope.userData = userInfo; 537 $rootScope.userData = userInfo;
432 $rootScope.userModules = userInfo.Modules; 538 $rootScope.userModules = userInfo.Modules;
433 $rootScope.isVisibleLogin = false; 539 $rootScope.isVisibleLogin = false;
434 - //$rootScope.haveRoleAdmin = true; 540 +
435 541
436 if ($rootScope.refreshcheck == null) { 542 if ($rootScope.refreshcheck == null) {
437 $location.path('/'); 543 $location.path('/');
@@ -451,11 +557,12 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic @@ -451,11 +557,12 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic
451 } 557 }
452 } 558 }
453 } 559 }
  560 +
454 } 561 }
455 catch (e) { 562 catch (e) {
456 localStorage.removeItem('loggedInUserDetails'); 563 localStorage.removeItem('loggedInUserDetails');
457 } 564 }
458 - } 565 +
459 } 566 }
460 567
461 $rootScope.SendMailToUser = function (userInfo, isMailForForgotPassword) { 568 $rootScope.SendMailToUser = function (userInfo, isMailForForgotPassword) {
400-SOURCECODE/AIAHTML5.Web/index.html
@@ -205,9 +205,12 @@ @@ -205,9 +205,12 @@
205 <span class="help-block text-right small "><a href="#" class="color-white">Forgot Password?</a></span>--> 205 <span class="help-block text-right small "><a href="#" class="color-white">Forgot Password?</a></span>-->
206 <div class="input-group"> 206 <div class="input-group">
207 <span class="input-group-addon"><i class="fa fa-key"></i></span> 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 </div> 209 </div>
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"--> 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 </div> 214 </div>
212 <div class="form-group"> 215 <div class="form-group">
213 <button class="btn btn-primary pull-right" ng-click="AuthenticateUser(userInfo)">Log In</button> 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
@@ -30,7 +30,7 @@ body { @@ -30,7 +30,7 @@ body {
30 footer { 30 footer {
31 color: #303030; 31 color: #303030;
32 font: 12px/30px 'Open Sans'; 32 font: 12px/30px 'Open Sans';
33 - margin-top: -55px; 33 + margin-top: -30px;
34 } 34 }
35 footer.dark { 35 footer.dark {
36 color: #ccc; 36 color: #ccc;
@@ -1276,4 +1276,9 @@ footer .browserIcons @@ -1276,4 +1276,9 @@ footer .browserIcons
1276 width:70%; 1276 width:70%;
1277 margin-left:15%; 1277 margin-left:15%;
1278 margin-top:25%; 1278 margin-top:25%;
1279 -}  
1280 \ No newline at end of file 1279 \ No newline at end of file
  1280 +}
  1281 +
  1282 +#UserPassword
  1283 + {
  1284 + -webkit-text-security: disc;
  1285 + }
1281 \ No newline at end of file 1286 \ No newline at end of file