From 765a47e5568f9f87b8f9eabddc98ef004c471fc9 Mon Sep 17 00:00:00 2001 From: Mukul Date: Mon, 23 Apr 2018 17:18:08 +0530 Subject: [PATCH] this is solution for the bug block five times --- 400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------- 1 file changed, 74 insertions(+), 50 deletions(-) diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js index 59ffc5f..8df1a9f 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js @@ -1,7 +1,7 @@ 'use strict'; -AIA.controller("HomeController", ["$rootScope", "Modules", "$log", "$location", "$timeout", "DataService", "AuthenticationService", "LoginConstants", "UserModules", "LoginMessageConstants", "AdminService", "$http", "AdminConstants", "UserTypeConstants", "AIAConstants", -function ($rootScope, Modules, $log, $location, $timeout, DataService, AuthenticationService, LoginConstants, UserModules, LoginMessageConstants, AdminService, $http, AdminConstants, UserTypeConstants,AIAConstants) { +AIA.controller("HomeController", ["$rootScope", "$scope", "Modules", "$log", "$location", "$timeout", "DataService", "AuthenticationService", "LoginConstants", "UserModules", "LoginMessageConstants", "AdminService", "$http", "AdminConstants", "UserTypeConstants", "AIAConstants", +function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, AuthenticationService, LoginConstants, UserModules, LoginMessageConstants, AdminService, $http, AdminConstants, UserTypeConstants,AIAConstants) { //$scope.pageToOpen = { // name: 'MainMenu' @@ -42,8 +42,8 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic $rootScope.current_year = AIAConstants.current_year; // 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. $rootScope.refreshcheck = null; - - $rootScope.isLoginAvilableModel = true; + var isCommingSoonModel = true; + $rootScope.isCloseSettingClicked = false; @@ -142,9 +142,15 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic $rootScope.isVisibleResetPass = true; } else { - $rootScope.isVisibleLogin = true; - $rootScope.isVisibleResetPass = false; - getUserDetails(); + + $rootScope.isVisibleLogin = true; + $rootScope.isVisibleResetPass = false; + + //get user is already loggedin or not + $scope.currentUserDetails = $rootScope.getLocalStorageValue('loggedInUserDetails'); + if ($scope.currentUserDetails != undefined) { + AuthenticateAlreadyLoggedInUser(); + } } } @@ -161,24 +167,23 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic $rootScope.AuthenticateUser = function (userInfo) { - alert("sdfsdf" + $rootScope.isLoginAvilableModel); + if (navigator.cookieEnabled) { - $rootScope.errorMessage = ""; - if (userInfo.username == "" || userInfo.username == null || userInfo.password == "" || userInfo.password == null) { + if (userInfo.username == "" || userInfo.username == null || userInfo.username == undefined || userInfo.password == "" || userInfo.password == null || userInfo.password == undefined) { // alert(LoginMessageConstants.USER_CREDENTIALS_MISSING); $rootScope.errorMessage = LoginMessageConstants.USER_CREDENTIALS_MISSING; $("#messageModal").modal('show'); } else { - + + AuthenticationService.authenticateUser(userInfo) .then( function (result) { - - + if (result == LoginConstants.USER_NOT_FOUND) { $rootScope.isVisibleLogin = true; // alert(LoginMessageConstants.USER_OR_PASSWORD_INCORRECT); @@ -186,6 +191,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic $("#messageModal").modal('show'); } else { + if (typeof result.LoginId != undefined || result.LoginId != "" || result.LoginId != null) { if ($("#messageModal").length > 0) { @@ -246,36 +252,53 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic $("#messageModal").modal('show'); } else { - debugger; - //if (result.UserType == UserTypeConstants.SUPER_ADMIN && result.IsActive) { //(!result.IsSubscriptionExpired) && - if (result.LicenseId == 0 && result.IsActive) { - $rootScope.userData = result; - $rootScope.userModules = result.Modules; - $rootScope.isVisibleLogin = false; + + //LicenseId would be zero for admin that is why we set the haveRoleAdmin = true + if (result.LicenseId == 0 && result.IsActive) + { $rootScope.haveRoleAdmin = true; - localStorage.setItem('loggedInUserDetails', JSON.stringify(result)); - alert("first" + $rootScope.isLoginAvilableModel); - if (($rootScope.isLoginAvilableModel == true) && ($rootScope.refreshcheck == null)) + + $rootScope.userData = result; + $rootScope.userModules = result.Modules; + + if ($scope.currentUserDetails == null || $scope.currentUserDetails == undefined || $scope.currentUserDetails == "") { + localStorage.setItem('loggedInUserDetails', JSON.stringify(result)); + } + + if (isCommingSoonModel == true) { - - ShowAssignedModulesPopup(result.Modules); - localStorage.setItem('isLoginAvilableModel',false); + + ShowAssignedModulesPopup(result.Modules); + $rootScope.isVisibleLogin = false; + localStorage.setItem('isCommingSoonModel', false); } - + + $location.path('/'); } else { - if (result.LicenseInfo != null && result.LicenseInfo.IsTermAccepted) { + if (result.LicenseInfo != null && result.LicenseInfo.IsTermAccepted) + { $rootScope.userData = result; $rootScope.userModules = result.Modules; - $rootScope.isVisibleLogin = false; + + //set haveRoleAdmin = false because LicenseInfo is not null $rootScope.haveRoleAdmin = false; - localStorage.setItem('loggedInUserDetails', JSON.stringify(result)); - if (($rootScope.isLoginAvilableModel) && ($rootScope.refreshcheck == null)) { + + if ($scope.currentUserDetails == null || $scope.currentUserDetails == undefined || $scope.currentUserDetails == "") { + + localStorage.setItem('loggedInUserDetails', JSON.stringify(result)); + } + + if (isCommingSoonModel == true) { + ShowAssignedModulesPopup(result.Modules); - localStorage.setItem('isLoginAvilableModel', false); + $rootScope.isVisibleLogin = false; + localStorage.setItem('isCommingSoonModel', false); } + + $location.path('/'); } @@ -407,33 +430,33 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic $rootScope.isVisibleLogin = true; } - function getUserDetails() { //Retain logged in user details - var currentUserDetails = $rootScope.getLocalStorageValue('loggedInUserDetails'); - $rootScope.isLoginAvilableModel = $rootScope.getLocalStorageValue('isLoginAvilableModel'); - if (currentUserDetails) { + function AuthenticateAlreadyLoggedInUser() + { + + isCommingSoonModel = $rootScope.getLocalStorageValue('isCommingSoonModel'); + try { - var userInfo = JSON.parse(currentUserDetails); + var userInfo = JSON.parse($scope.currentUserDetails); if (userInfo.LoginId != undefined || userInfo.LoginId != "" || userInfo.LoginId != null) { - if (userInfo.UserType == UserTypeConstants.SUPER_ADMIN && userInfo.IsActive) { //(!result.IsSubscriptionExpired) && - - $rootScope.userData = userInfo; - + if (userInfo.UserType == UserTypeConstants.SUPER_ADMIN && userInfo.IsActive) { + + //0 + $rootScope.userData = userInfo; $rootScope.userModules = userInfo.Modules; + + //1. userInfo["username"] = userInfo.LoginId; userInfo["password"] = userInfo.Password; + //2. $rootScope.AuthenticateUser(userInfo); - // $rootScope.isVisibleLogin = false; + $rootScope.haveRoleAdmin = true; if ($rootScope.refreshcheck == null) { - //setTimeout(function () { - - // $('#dvUserModulesInfo').modal('hide') - - //}, 400); + if ($location.path() == "/lab-exercises-detail") { $location.url('/'); @@ -442,7 +465,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic $location.path('/'); } - + $rootScope.isVisibleLogin = false; } } @@ -451,11 +474,12 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic { $rootScope.haveRoleAdmin = false; - if (userInfo.LicenseInfo.IsTermAccepted) { + if (userInfo.LicenseInfo.IsTermAccepted) + { $rootScope.userData = userInfo; $rootScope.userModules = userInfo.Modules; $rootScope.isVisibleLogin = false; - //$rootScope.haveRoleAdmin = true; + if ($rootScope.refreshcheck == null) { $location.path('/'); @@ -479,7 +503,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic catch (e) { localStorage.removeItem('loggedInUserDetails'); } - } + } $rootScope.SendMailToUser = function (userInfo, isMailForForgotPassword) { -- libgit2 0.21.4