diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs index 89879c4..41bf612 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/UserController.cs @@ -119,10 +119,10 @@ namespace AIAHTML5.ADMIN.API.Controllers bool Status = false; int userId = jsonData["userId"].Value(); string tagName = jsonData["tagName"].Value(); - bool isAlreadyLoggedIn = jsonData["isAlreadyLoggedIn"].Value(); + long SessionId = jsonData["SessionId"].Value(); try { - Status = UserModel.ManageUserLoginStatus(dbContext, userId, tagName, isAlreadyLoggedIn); + Status = UserModel.ManageUserLoginStatus(dbContext, userId, tagName, SessionId); return Request.CreateResponse(HttpStatusCode.OK, Status.ToString()); } diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.Context.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.Context.cs index 7bc70fe..d5540dc 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.Context.cs +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.Context.cs @@ -4995,7 +4995,7 @@ namespace AIAHTML5.ADMIN.API.Entity return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("usp_InsertAIAUser", sLoginIdParameter, sPasswordParameter, sFirstnameParameter, sLastnameParameter, iUserTypeIdParameter, sEmailIdParameter, iSecurityQuesIdParameter, sSecurityAnswerParameter, iCreatorIdParameter, iLicenseIdParameter, iEditionIdParameter, status); } - public virtual ObjectResult> usp_ManageUserLoginStatus(Nullable userId, string tag, Nullable isAlreadyLogin) + public virtual ObjectResult> usp_ManageUserLoginStatus(Nullable userId, string tag, Nullable sessionId) { var userIdParameter = userId.HasValue ? new ObjectParameter("userId", userId) : @@ -5005,11 +5005,11 @@ namespace AIAHTML5.ADMIN.API.Entity new ObjectParameter("tag", tag) : new ObjectParameter("tag", typeof(string)); - var isAlreadyLoginParameter = isAlreadyLogin.HasValue ? - new ObjectParameter("isAlreadyLogin", isAlreadyLogin) : - new ObjectParameter("isAlreadyLogin", typeof(bool)); + var sessionIdParameter = sessionId.HasValue ? + new ObjectParameter("sessionId", sessionId) : + new ObjectParameter("sessionId", typeof(long)); - return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction>("usp_ManageUserLoginStatus", userIdParameter, tagParameter, isAlreadyLoginParameter); + return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction>("usp_ManageUserLoginStatus", userIdParameter, tagParameter, sessionIdParameter); } } } diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.edmx b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.edmx index 17280a6..acab4d3 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.edmx +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.edmx @@ -1410,7 +1410,7 @@ - + @@ -3006,7 +3006,7 @@ - + diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/UserModel.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/UserModel.cs index ca0ce88..2ec74fc 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/UserModel.cs +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Models/UserModel.cs @@ -65,12 +65,12 @@ namespace AIAHTML5.ADMIN.API.Models return false; } } - public static bool ManageUserLoginStatus(AIADatabaseV5Entities dbContext, int userId, string tagName, bool isAlreadyLoggedIn) + public static bool ManageUserLoginStatus(AIADatabaseV5Entities dbContext, int userId, string tagName, long SessionId) { bool loginStatus = false; try { - loginStatus = Convert.ToBoolean(dbContext.usp_ManageUserLoginStatus(userId, tagName, isAlreadyLoggedIn).FirstOrDefault()); + loginStatus = Convert.ToBoolean(dbContext.usp_ManageUserLoginStatus(userId, tagName, SessionId).FirstOrDefault()); return loginStatus; } diff --git a/400-SOURCECODE/AIAHTML5.API/Controllers/AuthenticateController.cs b/400-SOURCECODE/AIAHTML5.API/Controllers/AuthenticateController.cs index aab070e..554456b 100644 --- a/400-SOURCECODE/AIAHTML5.API/Controllers/AuthenticateController.cs +++ b/400-SOURCECODE/AIAHTML5.API/Controllers/AuthenticateController.cs @@ -370,9 +370,9 @@ namespace AIAHTML5.API.Controllers { int userId = jsonData["userId"].Value(); string tagName = jsonData["tagName"].Value(); - bool isAlreadyLoggedIn = jsonData["isAlreadyLoggedIn"].Value(); + long SessionId = jsonData["SessionId"].Value(); - loginStatus = AIAHTML5.API.Models.Users.GetUserLoginStatus(userId, tagName, isAlreadyLoggedIn); + loginStatus = AIAHTML5.API.Models.Users.GetUserLoginStatus(userId, tagName, SessionId); return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(loginStatus) }; } diff --git a/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs b/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs index 845b9f8..1ffe8e0 100644 --- a/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs +++ b/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs @@ -310,7 +310,7 @@ namespace AIAHTML5.API.Models return objUser; } - internal static string GetUserLoginStatus(int userId,string tagName,bool isAlreadyLoggedIn) + internal static string GetUserLoginStatus(int userId,string tagName, long SessionId) { string status=string.Empty; DBModel objModel = new DBModel(); @@ -325,7 +325,7 @@ namespace AIAHTML5.API.Models cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@userId", userId); cmd.Parameters.AddWithValue("@tag", tagName); - cmd.Parameters.AddWithValue("@isAlreadyLogin", isAlreadyLoggedIn); + cmd.Parameters.AddWithValue("@sessionId", SessionId); adapter = new SqlDataAdapter(cmd); adapter.Fill(ds); diff --git a/400-SOURCECODE/AIAHTML5.API/Models/Users.cs b/400-SOURCECODE/AIAHTML5.API/Models/Users.cs index cbfac22..e591b81 100644 --- a/400-SOURCECODE/AIAHTML5.API/Models/Users.cs +++ b/400-SOURCECODE/AIAHTML5.API/Models/Users.cs @@ -306,10 +306,10 @@ namespace AIAHTML5.API.Models } - internal static string GetUserLoginStatus(int userId, string tagName,bool isAlreadyLoggedIn) + internal static string GetUserLoginStatus(int userId, string tagName, long SessionId) { string status = null; - status = DBModel.GetUserLoginStatus(userId, tagName, isAlreadyLoggedIn); + status = DBModel.GetUserLoginStatus(userId, tagName, SessionId); return status; } diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js index cac6bb4..8544086 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js @@ -78,32 +78,11 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A //$rootScope.errorMessage = ''; // Commented initialization to retain message when coming to login after password reset success screen $rootScope.disableFileMenu = "disableFileMenu"; - $rootScope.userInfo = { - username: null, - password: null, - emailId: null, - newPassword: null, - confirmPassword: null, - userMessage: null, - unblockUser: false, - isMailForForgotPassword:false - }; $rootScope.userLicenseInfo = { userLicenseId: 0, licenseeAccountNumber: null }; - $rootScope.siteUrlInfo = { - siteIP: null, - remoteIPAddress:null, - status: null, - accountNumber: null, - edition: null, - urlReferer: null, - calsCreds: null, - userId: null, - password:null - } $rootScope.userData; $rootScope.userModules; $rootScope.passwordMismatchMessage; @@ -134,7 +113,35 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A } $rootScope.initializeAIA = function () { - if (params != null && params != undefined && params!="") { + var date = new Date(); + $rootScope.userInfo = { + username: null, + password: null, + emailId: null, + newPassword: null, + confirmPassword: null, + userMessage: null, + unblockUser: false, + isMailForForgotPassword: false, + SessionId:date.getTime() + }; + + $rootScope.siteUrlInfo = { + siteIP: null, + remoteIPAddress: null, + status: null, + accountNumber: null, + edition: null, + urlReferer: null, + calsCreds: null, + userId: null, + password: null, + mtype:null, + id:null, + SessionId:date.getTime() + } + + if (params != null && params != undefined && params != "") { $scope.ValidateClientSiteUrl(); } @@ -166,6 +173,7 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A $scope.currentUserDetails = $rootScope.getLocalStorageValue('loggedInUserDetails'); if ($scope.currentUserDetails != undefined) { $rootScope.isVisibleLogin = false; + $location.url('/'); ConfigurationService.getCofigValue() .then( function (configresult) { @@ -181,7 +189,7 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A $scope.checkuserstatus = { userId: userId, tagName: loggedInUser.Id==0?'logout':'update', - isAlreadyLoggedIn:true + SessionId:loggedInUser.SessionId } // this case found when browser closed by user after login. after long time (after 20 min) open site again @@ -259,6 +267,12 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A $('#spinnerLogin').css('visibility', 'hidden'); $('.loginPanel').css('pointer-events', 'auto'); $('.loginPanel').css('opacity', '1'); + + $rootScope.isLoading = false; + $('#spinner').css('visibility', 'hidden'); + $('#HomeContainerDiv').css('pointer-events', 'auto'); + $('#HomeContainerDiv').css('opacity', '1'); + } $rootScope.LoginDisableUI=function() { @@ -266,8 +280,14 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A $('#spinnerLogin').css('visibility', 'visible'); $('.loginPanel').css('pointer-events', 'none'); $('.loginPanel').css('opacity', '0.7'); + + $rootScope.isLoading = true; + $('#spinner').css('visibility', 'visible'); + $('#HomeContainerDiv').css('pointer-events', 'none'); + $('#HomeContainerDiv').css('opacity', '0.7'); + } - $rootScope.AuthenticateUser = function (userInfo,isAlreadyLoggedIn) { + $rootScope.AuthenticateUser = function (userInfo) { if (navigator.cookieEnabled) { $rootScope.errorMessage = ""; if (userInfo.username == "" || userInfo.username == null || userInfo.username == undefined || userInfo.password == "" || userInfo.password == null || userInfo.password == undefined) { @@ -299,7 +319,8 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A result.aiaIdleTime=$rootScope.aiaIdleTime; result.aiaIdleTimeOut=$rootScope.aiaIdleTimeOut; result.aiaPingInterval=$rootScope.aiaPingInterval; - $rootScope.isAlreadyLoggedIn=isAlreadyLoggedIn==undefined?false:isAlreadyLoggedIn; + result.SessionId=userInfo.SessionId; + //display user name $rootScope.userName=result.FirstName+" "+result.LastName; @@ -684,17 +705,21 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A //maintain user session by licenseid of site login if(loggedInUser!==null && loggedInUser.AccountNumber==sitedetail.accountNumber) { - $rootScope.AuthenticateClientSiteUser(sitedetail,true); + //using old session id + sitedetail.SessionId = loggedInUser.SessionId; + $rootScope.AuthenticateClientSiteUser(sitedetail); } else { - $rootScope.AuthenticateClientSiteUser(sitedetail,false); + //using new sessionid + $rootScope.AuthenticateClientSiteUser(sitedetail); } }); } } - $rootScope.AuthenticateClientSiteUser = function (siteInfo,isAlreadyLoggedIn) { + $rootScope.AuthenticateClientSiteUser = function (siteInfo) { + $rootScope.LoginDisableUI(); AuthenticationService.validateClientSite(siteInfo) .then( function (result) { @@ -745,7 +770,7 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A result.aiaIdleTime=$rootScope.aiaIdleTime; result.aiaIdleTimeOut=$rootScope.aiaIdleTimeOut; result.aiaPingInterval=$rootScope.aiaPingInterval; - $rootScope.isAlreadyLoggedIn=isAlreadyLoggedIn==undefined?false:isAlreadyLoggedIn; + result.SessionId=siteInfo.SessionId; //display user name $rootScope.userName=result.FirstName+" "+result.LastName; if (typeof result.FirstName != undefined || result.FirstName != "" || result.FirstName != null) { @@ -1047,11 +1072,10 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A $rootScope.userStatus = { userId: null, tagName: null, - loginStatus: null, - isAlreadyLoggedIn:null + SessionId:null } console.log('user session start'); - $rootScope.CheckUserSession('insert',$rootScope.isAlreadyLoggedIn); + $rootScope.CheckUserSession('insert'); $rootScope.$on('IdleStart', function() { // this event fire when idle time finish and time out start @@ -1069,14 +1093,14 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A // config set in AIA.js -:IdleProvider.timeout(15); $rootScope.isSessionTimeout=true; console.log('session is timeout'); - $rootScope.CheckUserSession('logout',true); + $rootScope.CheckUserSession('logout'); }); $rootScope.$on('Keepalive', function() { // it watch the session on perticular time interval during idle time period // config set in AIA.js -: KeepaliveProvider.interval(10); //we will use it to recieve request from databse if user logout from admin activity console.log('ping user session'); - $rootScope.CheckUserSession('update',true); + $rootScope.CheckUserSession('update'); }); @@ -1103,7 +1127,7 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A $rootScope.isSessionTimeout=true; localStorage.removeItem('loggedInUserDetails'); localStorage.clear(); - $rootScope.CheckUserSession('logout',true); + $rootScope.CheckUserSession('logout'); $timeout(function(){ document.location = '/'; $rootScope.isVisibleLogin = true; @@ -1118,15 +1142,15 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A $rootScope.isVisibleLogin = true; } - $rootScope.CheckUserSession = function (tagName,isAlreadyLoggedIn) { + $rootScope.CheckUserSession = function (tagName) { //console.log('user login id: '+$rootScope.userData.Id); //console.log('user login activity tag: '+tagName); if($rootScope.userData==undefined) return; //incase site user login userid is 0 so then using license id $rootScope.userStatus.userId=$rootScope.userData.Id==0?$rootScope.userData.LicenseId:$rootScope.userData.Id; $rootScope.userStatus.tagName=tagName; - $rootScope.userStatus.isAlreadyLoggedIn=isAlreadyLoggedIn; - $rootScope.isAlreadyLoggedIn=true; + $rootScope.userStatus.SessionId=$rootScope.userData.SessionId; + AuthenticationService.ManageUserLoginStatus($rootScope.userStatus) .then( function (loginStatus) { @@ -1162,20 +1186,7 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A userInfo["password"] = userInfo.Password; - $rootScope.AuthenticateUser(userInfo,true); - - if ($rootScope.refreshcheck == null) { - - if ($location.path() == "/lab-exercises-detail") { - - $location.url('/'); - } - else { - - $location.url('/'); - } - $rootScope.isVisibleLogin = false; - } + $rootScope.AuthenticateUser(userInfo); } diff --git a/400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js b/400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js index 4d24067..352b7df 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js @@ -57,8 +57,8 @@ }).error(function (data, status, headers, config) { console.log('error') deferred.reject(data); - $rootScope.errorMessage = data; - $("#messageModal").modal('show'); + // $rootScope.errorMessage = data; + // $("#messageModal").modal('show'); }); return deferred.promise; diff --git a/400-SOURCECODE/AIAHTML5.Web/index.aspx b/400-SOURCECODE/AIAHTML5.Web/index.aspx index d089fd8..052bc60 100644 --- a/400-SOURCECODE/AIAHTML5.Web/index.aspx +++ b/400-SOURCECODE/AIAHTML5.Web/index.aspx @@ -308,7 +308,7 @@
-
+