From 913d69ee2b7c7682a44a5f29ec7be1ac72fd87d7 Mon Sep 17 00:00:00 2001 From: nikita Date: Thu, 30 Aug 2018 21:24:46 +0530 Subject: [PATCH] completed site url intergartiion. Landing page image is not loaded --- 400-SOURCECODE/AIAHTML5.API/Controllers/ClientController.cs | 25 +++++++++++++++++++------ 400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs | 2 +- 400-SOURCECODE/AIAHTML5.API/Models/Users.cs | 2 +- 400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js | 287 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------- 400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js | 7 ++++++- 400-SOURCECODE/AIAHTML5.Web/index.aspx | 2 +- 400-SOURCECODE/AIAHTML5.Web/index.aspx.cs | 4 ++-- 7 files changed, 270 insertions(+), 59 deletions(-) diff --git a/400-SOURCECODE/AIAHTML5.API/Controllers/ClientController.cs b/400-SOURCECODE/AIAHTML5.API/Controllers/ClientController.cs index 968376b..4209f1e 100644 --- a/400-SOURCECODE/AIAHTML5.API/Controllers/ClientController.cs +++ b/400-SOURCECODE/AIAHTML5.API/Controllers/ClientController.cs @@ -10,6 +10,7 @@ using Newtonsoft.Json.Linq; using System.Data.SqlClient; using System.Collections; using log4net; +using Newtonsoft.Json; namespace AIAHTML5.API.Controllers { @@ -32,16 +33,20 @@ namespace AIAHTML5.API.Controllers { ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); logger.Debug("inside POST in ClientController"); - - HttpResponseMessage response = null; - try + try{ + HttpResponseMessage response = null; + if (siteUrl != null) { - int siteId = AIAHTML5.API.Models.Users.ValidateLicenseSiteIP(siteUrl["siteIP"].ToString(), siteUrl["remoteIPAddress"].ToString(), siteUrl["accountNumber"].ToString(), Convert.ToByte(siteUrl["edition"].ToString())); + if (!string.IsNullOrEmpty(siteUrl["siteIP"].ToString()) && !string.IsNullOrEmpty(siteUrl["remoteIPAddress"].ToString()) && !string.IsNullOrEmpty(siteUrl["accountNumber"].ToString()) && !string.IsNullOrEmpty(siteUrl["edition"].ToString())) + + { + + int siteId = AIAHTML5.API.Models.Users.ValidateLicenseSiteIP(siteUrl["siteIP"].ToString(), siteUrl["remoteIPAddress"].ToString(), siteUrl["accountNumber"].ToString(), Convert.ToByte(siteUrl["edition"].ToString())); if (siteId > 0) { dynamic uerinfo = AIAHTML5.API.Models.Users.ValidateSiteLogin(siteUrl["siteIP"].ToString(), siteUrl["accountNumber"].ToString(), siteUrl["urlReferer"].ToString(), siteUrl["edition"].ToString(), siteId); if (uerinfo != null) - response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(uerinfo) }; + response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(uerinfo)) }; else { //ser user = new User(); @@ -52,12 +57,20 @@ namespace AIAHTML5.API.Controllers response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(AIAConstants.INVALID_CLIENT) }; } } + else { response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(AIAConstants.MSG_NOT_AUTHORIZE_SITE_USER) }; - } + } + } + else + { + response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = null }; + + } + return response; } catch (SqlException e) diff --git a/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs b/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs index a7387b9..11be152 100644 --- a/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs +++ b/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs @@ -1115,7 +1115,7 @@ namespace AIAHTML5.API.Models { foreach (DataRow dr in dt.Rows) { - if ((bool)dr["IsActive"]) + if (Convert.ToBoolean(dr["IsActive"])) { objFeatures.Add(dr["Id"], dr["Title"]); } diff --git a/400-SOURCECODE/AIAHTML5.API/Models/Users.cs b/400-SOURCECODE/AIAHTML5.API/Models/Users.cs index 6e6babb..1883ca1 100644 --- a/400-SOURCECODE/AIAHTML5.API/Models/Users.cs +++ b/400-SOURCECODE/AIAHTML5.API/Models/Users.cs @@ -488,7 +488,7 @@ namespace AIAHTML5.API.Models if (userInfo.LicenseInfo != null) { //05.3 get licenseSubscription details - userInfo.LicenseSubscriptions = AIAHTML5.API.Models.Users.getLicenseSubscriptionDetails(userInfo.LicenseId); + userInfo.LicenseSubscriptions = AIAHTML5.API.Models.Users.getLicenseSubscriptionDetails( userInfo.LicenseInfo.Id); //05.4 check the License expiration irespective of either user is active or not because on AIA //we shows the License expiration message for inactive users too diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js index 58b7625..092fcc5 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js @@ -133,9 +133,9 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A } - + $rootScope.initializeAIA = function () { - if (urlParams != null && urlParams != undefined) { + if (params != null && params != undefined && params!="") { $scope.ValidateClientSiteUrl(); } @@ -402,65 +402,259 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A $scope.ValidateClientSiteUrl = function () { + debugger var siteInfo = params.split('&'); - for (var i = 0; i < siteInfo.length; i++) - { - if (isCalsCredantial) { - var paramInfo = siteInfo[i].split('='); - if (paramInfo[0] == 'calsCredantial') { + for (var i = 0; i < siteInfo.length; i++) { + debugger; + if (isCalsCredantialForSIte == "True") { + var paramInfo = siteInfo[i].split('='); + if (paramInfo[0] == 'calsCredantial') { - $rootScope.siteUrlInfo.calsCreds = paramInfo[1]; - } - else if (paramInfo[0] == 'username') { + $rootScope.siteUrlInfo.calsCreds = paramInfo[1]; + console.log("$rootScope.siteUrlInfo.calsCreds" + $rootScope.siteUrlInfo.calsCreds); + } + else if (paramInfo[0] == 'username') { - $rootScope.siteUrlInfo.username = paramInfo[1]; - } - else if (paramInfo[0] == 'password') { + $rootScope.siteUrlInfo.username = paramInfo[1]; + console.log("$rootScope.siteUrlInfo.username" + $rootScope.siteUrlInfo.username); + } + else if (paramInfo[0] == 'password') { - $rootScope.siteUrlInfo.password = paramInfo[1]; - } + $rootScope.siteUrlInfo.password = paramInfo[1]; + console.log("$rootScope.siteUrlInfo.password " + $rootScope.siteUrlInfo.password); + } - $rootScope.userInfo.username = $rootScope.siteUrlInfo.username; - $rootScope.userInfo.password = $rootScope.siteUrlInfo.password; + $rootScope.userInfo.username = $rootScope.siteUrlInfo.username; + $rootScope.userInfo.password = $rootScope.siteUrlInfo.password; + console.log("$rootScope.userInfo.username" + $rootScope.userInfo.username + " $rootScope.userInfo.password" + $rootScope.userInfo.password); - $rootScope.AuthenticateUser($rootScope.userInfo); - } - else{ - var paramInfo = siteInfo[i].split('='); - if (paramInfo[0] == 'siteIP') { + } + else { + var paramInfo = siteInfo[i].split('='); + if (paramInfo[0] == 'siteIP') { - $rootScope.siteUrlInfo.siteIP = paramInfo[1]; - } - else if (paramInfo[0] == 'accountNumber') { + $rootScope.siteUrlInfo.siteIP = paramInfo[1]; + console.log("$rootScope.siteUrlInfo.siteIP=" + $rootScope.siteUrlInfo.siteIP); + } + else if (paramInfo[0] == 'accountNumber') { - $rootScope.siteUrlInfo.accountNumber = paramInfo[1]; - } - else if (paramInfo[0] == 'edition') { + $rootScope.siteUrlInfo.accountNumber = paramInfo[1]; + console.log("$rootScope.siteUrlInfo.accountNumber=" + $rootScope.siteUrlInfo.accountNumber); + } + else if (paramInfo[0] == 'edition') { - $rootScope.siteUrlInfo.siteIP = paramInfo[1]; - } - else if (paramInfo[0] == 'urlReferer') { + $rootScope.siteUrlInfo.edition = paramInfo[1]; + console.log("$rootScope.siteUrlInfo.siteIP=" + $rootScope.siteUrlInfo.siteIP); + } + else if (paramInfo[0] == 'urlReferer') { - $rootScope.siteUrlInfo.siteIP = paramInfo[1]; - } - else if (paramInfo[0] == 'remoteIPAddress') { + $rootScope.siteUrlInfo.urlReferer = paramInfo[1]; + console.log("$rootScope.siteUrlInfo.siteIP" + $rootScope.siteUrlInfo.siteIP); + } + else if (paramInfo[0] == 'remoteIPAddress') { - $rootScope.siteUrlInfo.remoteIPAddress = paramInfo[1]; - } + $rootScope.siteUrlInfo.remoteIPAddress = paramInfo[1]; + console.log("$rootScope.siteUrlInfo.remoteIPAddress" + $rootScope.siteUrlInfo.remoteIPAddress); + } - AuthenticationService.validateClientSite($rootScope.siteUrlInfo) - .then( - function (result) { - console.log(result); - - }, - function (error) { } - ) - } - } + } + } + if (isCalsCredantialForSIte == "True") { + $rootScope.AuthenticateUser($rootScope.userInfo); + } + else { + + + console.log($rootScope.siteUrlInfo); + + AuthenticationService.validateClientSite($rootScope.siteUrlInfo) + .then( + + function (result) { + debugger; + console.log(result); + if (result != null) { + + + console.log(result); + if (result == LoginConstants.INVALID_CLIENT) { + $rootScope.isVisibleLogin = true; + $rootScope.errorMessage = LoginConstants.INVALID_CLIENT; + $("#messageModal").modal('show'); + } + else if (result == LoginConstants.MSG_NOT_AUTHORIZE_SITE_USER) { + $rootScope.isVisibleLogin = true; + $rootScope.errorMessage = LoginConstants.MSG_NOT_AUTHORIZE_SITE_USER; + $("#messageModal").modal('show'); + } + + else if (result.LoginFailureCauseId != undefined && result.LoginFailureCauseId.toString() == LoginConstants.E_ACCOUNT_NUMBER_NOT_NULL) { + $rootScope.isVisibleLogin = true; + $rootScope.errorMessage = LoginMessageConstants.E_ACCOUNT_NUMBER_NOT_NULL; + $("#messageModal").modal('show'); + } + else if (result.LoginFailureCauseId != undefined && result.LoginFailureCauseId.toString() == LoginConstants.E_EDITION_ID_NOT_NULL) { + $rootScope.isVisibleLogin = true; + $rootScope.errorMessage = LoginMessageConstants.E_EDITION_ID_NOT_NULL; + $("#messageModal").modal('show'); + } + else if (result.LoginFailureCauseId != undefined && result.LoginFailureCauseId.toString() == LoginConstants.E_EDITION_NOT_LINKED_WITH_SITE) { + $rootScope.isVisibleLogin = true; + $rootScope.errorMessage = LoginMessageConstants.E_EDITION_NOT_LINKED_WITH_SITE; + $("#messageModal").modal('show'); + } + else if (result.LoginFailureCauseId != undefined && result.LoginFailureCauseId.toString() == LoginConstants.LICENSE_INACTIVE) { + $rootScope.isVisibleLogin = true; + $rootScope.errorMessage = LoginMessageConstants.LICENSE_INACTIVE_MESSAGE; + $("#messageModal").modal('show'); + } + + + else { + if (typeof result.FirstName != undefined || result.FirstName != "" || result.FirstName != null) { + //code for modesty setting + if (result.LicenseInfo != null) { + if (result.Modesty) { + $rootScope.isModestyOn = true; + $rootScope.isModestyOff = false; + localStorage.setItem("globalModesty", "Y"); + $rootScope.formsetting = { + ethnicity: null, + modesty: "Y" + } + $rootScope.UpdateAndCloseSetting($rootScope.formsetting) + } + else { + $rootScope.isModestyOn = false; + $rootScope.isModestyOff = true; + localStorage.setItem("globalModesty", "N"); + $rootScope.formsetting = { + ethnicity: null, + modesty: "N" + } + $rootScope.UpdateAndCloseSetting($rootScope.formsetting) + } + } + else { + $rootScope.isModestyOn = true; + $rootScope.isModestyOff = false; + localStorage.setItem("globalModesty", "Y"); + $rootScope.formsetting = { + ethnicity: null, + modesty: "Y" + } + $rootScope.UpdateAndCloseSetting($rootScope.formsetting) + } + //code for modesty setting + + + + + //LicenseId would be zero for admin that is why we set the haveRoleAdmin = true + if (result.LicenseId == 0) { + $rootScope.haveRoleAdmin = true; + + $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); + + //if (userInfo.rememberChk) { + + // $scope.saveRemeberMeDetails(result, userInfo); + //} + + sessionStorage.setItem("loginSession", "true"); + localStorage.setItem('isCommingSoonModel', false); + + $rootScope.isVisibleLogin = false; + } + + + $location.path('/'); + + } + else { + if (result.LicenseInfo != null ) { + //0. + $rootScope.userData = result; + $rootScope.userModules = result.Modules; + + //1. set haveRoleAdmin = false because LicenseInfo is not null + $rootScope.haveRoleAdmin = false; + + //2. + if ($scope.currentUserDetails == null || $scope.currentUserDetails == undefined || $scope.currentUserDetails == "") { + + localStorage.setItem('loggedInUserDetails', JSON.stringify(result)); + } + + // 3.ShowAssignedModulesPopup + //isCommingSoonModel =true only when user comes first time on application and login + //if (isCommingSoonModel == true) { + + // ShowAssignedModulesPopup(result.Modules); + //} + + //4. + //if ($scope.rememberChk) { + + // $scope.saveRemeberMeDetails(result, userInfo); + //} + + //5. + sessionStorage.setItem("loginSession", "true"); + $rootScope.isVisibleLogin = false; + + //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 + // localStorage.setItem('isCommingSoonModel', false); + + $location.path('/'); + + } + else { + if ($('#dvTerms').length > 0) { + $('#dvTerms').html(result.TermsAndConditionsText); + } + $rootScope.isVisibleLogin = true; + $('#dvTermCondition').fadeIn(); + $rootScope.userData = result; + $rootScope.haveRoleAdmin = false; + localStorage.setItem('loggedInUserDetails', JSON.stringify(result)); + $location.path('/'); + } + } + } + + + } + } + + + + }, + + function (error) { + + console.log(' Error in authentication = ' + error.statusText); + // alert(LoginMessageConstants.ERROR_IN_FECTHING_DETAILS); + $rootScope.isVisibleLogin = true; + $rootScope.errorMessage = error; + $("#messageModal").modal('show'); + + } + ) + + } //$rootScope.siteUrlInfo.siteIP = siteInfo[0]; //$rootScope.siteUrlInfo.remoteIPAddress = siteInfo[1]; //$rootScope.siteUrlInfo.accountNumber = siteInfo[2]; @@ -470,7 +664,6 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A } - $scope.saveRemeberMeDetails = function (result, userInfo) { localStorage.setItem('RememberMeLoginId', result.LoginId); diff --git a/400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js b/400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js index eac86ac..470aa7c 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js @@ -361,7 +361,9 @@ AIA.constant("LoginConstants", { "ACCOUNT_NUMBER_NOT_EXIST": "1", "EDITION_NOT_EXIST": "3", "MASTER_SITEIP_NOT_EXIST": "2", - "LICENSE_INACTIVE": "6" + "LICENSE_INACTIVE": "6", + "INVALID_CLIENT": "Clinet is not valid", + "MSG_NOT_AUTHORIZE_SITE_USER": "User is not authorized.", }); AIA.constant("LoginMessageConstants", { @@ -400,6 +402,9 @@ AIA.constant("LoginMessageConstants", { "UNABLE_TO_UNBLOCK": "We are unable to unblock. Please try after sometime.", //"ERROR_IN_FECTHING_DETAILS": "Error in fecthing details.", //"MAIL_NOT_SENT": "Mail not sent." + "E_ACCOUNT_NUMBER_NOT_NULL": "Account number cannot be null", + "E_EDITION_ID_NOT_NULL": "Edition Id cannot be zero.", + "E_EDITION_NOT_LINKED_WITH_SITE": "Your credentials are invalid. Please contact the site administrator of your institution.", }) AIA.constant("AdminConstants", { diff --git a/400-SOURCECODE/AIAHTML5.Web/index.aspx b/400-SOURCECODE/AIAHTML5.Web/index.aspx index a7110f1..dc56890 100644 --- a/400-SOURCECODE/AIAHTML5.Web/index.aspx +++ b/400-SOURCECODE/AIAHTML5.Web/index.aspx @@ -164,7 +164,7 @@ diff --git a/400-SOURCECODE/AIAHTML5.Web/index.aspx.cs b/400-SOURCECODE/AIAHTML5.Web/index.aspx.cs index 3fa4e5f..4edd84d 100644 --- a/400-SOURCECODE/AIAHTML5.Web/index.aspx.cs +++ b/400-SOURCECODE/AIAHTML5.Web/index.aspx.cs @@ -15,13 +15,13 @@ namespace ADAM.AIA public string strEdition = ""; public string strUrlReferer = ""; public string strSiteReferer = ""; - public string urlParams = "?"; + public string urlParams = ""; public string test = ""; public bool isCalsCredantial = false; protected void Page_Load(object sender, EventArgs e) { - urlParams = "XYZ"; + if (Request.HttpMethod == "POST") { -- libgit2 0.21.4