From bb0d93c9f1b03a7012ebacb4af25b6f0f82baa31 Mon Sep 17 00:00:00 2001 From: Utkarsh Singh Date: Tue, 17 Oct 2017 14:56:47 +0530 Subject: [PATCH] Committing updated code to insert URL accessed to login in application --- 400-SOURCECODE/AIAHTML5.API/Controllers/AuthenticateController.cs | 15 ++++++++------- 400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs | 5 +++-- 400-SOURCECODE/AIAHTML5.API/Models/Users.cs | 6 +++--- 400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js | 4 +++- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/400-SOURCECODE/AIAHTML5.API/Controllers/AuthenticateController.cs b/400-SOURCECODE/AIAHTML5.API/Controllers/AuthenticateController.cs index 86f130b..e554e66 100644 --- a/400-SOURCECODE/AIAHTML5.API/Controllers/AuthenticateController.cs +++ b/400-SOURCECODE/AIAHTML5.API/Controllers/AuthenticateController.cs @@ -36,6 +36,7 @@ using System.Data.SqlClient;namespace AIAHTML5.API.Controllers dynamic authenticationRepsonse; DateTime blockTime; bool isUserBlocked; + string requestURL = credentials["currentURL"].ToString(); try { @@ -64,7 +65,7 @@ using System.Data.SqlClient;namespace AIAHTML5.API.Controllers logger.Fatal("Unable to delete past wrong login attempts for userId= " + userInfo.Id); } //05. - GetModulesBasedOnUserType(userInfo); + GetModulesBasedOnUserType(userInfo, requestURL); // authenticationRepsonse = JsonConvert.SerializeObject(userInfo); } @@ -92,7 +93,7 @@ using System.Data.SqlClient;namespace AIAHTML5.API.Controllers } //05. Now get the module list- for ADMIN (superadmin/ general admin) by default all module loads - GetModulesBasedOnUserType(userInfo); + GetModulesBasedOnUserType(userInfo, requestURL); } else @@ -180,7 +181,7 @@ using System.Data.SqlClient;namespace AIAHTML5.API.Controllers } - private static void GetModulesBasedOnUserType(User userInfo) + private static void GetModulesBasedOnUserType(User userInfo, string requestURL) { //based on old .net code(AIA flex), we get modules based on licenseId if licenseid>0. //we verified in database that only superadmin has no licenseid so getting all modules for supeadmin @@ -189,14 +190,14 @@ using System.Data.SqlClient;namespace AIAHTML5.API.Controllers userInfo.Modules = AIAHTML5.API.Models.Users.getAllModulesList(); //Insert user login detail - AIAHTML5.API.Models.Users.insertLoginDetails(userInfo.Id); + AIAHTML5.API.Models.Users.insertLoginDetails(userInfo.Id, requestURL); } else { CheckLicenseStatus(userInfo); if(!userInfo.IsSubscriptionExpired){ - GetModulesBasedOnLicense(userInfo,false); + GetModulesBasedOnLicense(userInfo, false, requestURL); } } } @@ -242,7 +243,7 @@ using System.Data.SqlClient;namespace AIAHTML5.API.Controllers } } - private static void GetModulesBasedOnLicense(User userInfo, bool isLicenseExpired) + private static void GetModulesBasedOnLicense(User userInfo, bool isLicenseExpired, string requestURL) { //05.6.1 @@ -262,7 +263,7 @@ using System.Data.SqlClient;namespace AIAHTML5.API.Controllers userInfo.Modules = AIAHTML5.API.Models.Users.getModuleListByLicenseId(userInfo.LicenseId); //Insert user login detail - AIAHTML5.API.Models.Users.insertLoginDetails(userInfo.Id); + AIAHTML5.API.Models.Users.insertLoginDetails(userInfo.Id, requestURL); } } else diff --git a/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs b/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs index 7128c81..df1997c 100644 --- a/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs +++ b/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs @@ -534,9 +534,9 @@ namespace AIAHTML5.API.Models return arrTermsAndConditions; } - internal int InsertLoginDetails(int userId) + internal int InsertLoginDetails(int userId, string requestURL) { - logger.Debug(" inside InsertLoginDetails for UserId= " + userId); + logger.Debug(" inside InsertLoginDetails for UserId= " + userId + ", URL: " + requestURL); int result = 0; try @@ -548,6 +548,7 @@ namespace AIAHTML5.API.Models cmd.CommandText = DBConstants.INSERT_LOGIN_DETAIL; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@iUserId", userId); + cmd.Parameters.AddWithValue("@CallFromURL", requestURL); result = cmd.ExecuteNonQuery(); } catch (SqlException ex) diff --git a/400-SOURCECODE/AIAHTML5.API/Models/Users.cs b/400-SOURCECODE/AIAHTML5.API/Models/Users.cs index 2cae71c..87e184e 100644 --- a/400-SOURCECODE/AIAHTML5.API/Models/Users.cs +++ b/400-SOURCECODE/AIAHTML5.API/Models/Users.cs @@ -134,15 +134,15 @@ namespace AIAHTML5.API.Models } - internal static int insertLoginDetails(int userId) + internal static int insertLoginDetails(int userId, string requestURL) { - logger.Debug("inside insertLoginDetails for UserId =" + userId); + logger.Debug("inside insertLoginDetails for UserId =" + userId + " & URL: " + requestURL); int result = 0; DBModel objModel = new DBModel(); - result = objModel.InsertLoginDetails(userId); + result = objModel.InsertLoginDetails(userId, requestURL); return result; } diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js index 0d1a77c..c748049 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js @@ -84,7 +84,8 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic confirmPassword: null, userMessage: null, unblockUser: false, - isMailForForgotPassword:false + isMailForForgotPassword: false, + currentURL: null }; $rootScope.userLicenseInfo = { userLicenseId: 0, @@ -145,6 +146,7 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic $("#messageModal").modal('show'); } else { + userInfo.currentURL = document.URL; AuthenticationService.authenticateUser(userInfo) .then( -- libgit2 0.21.4