From 56f6bcaa6985064b5d45f1e79bc4e2e97aec6bfb Mon Sep 17 00:00:00 2001 From: nikita Date: Mon, 27 Aug 2018 18:23:50 +0530 Subject: [PATCH] added more code --- 400-SOURCECODE/AIAHTML5.API/Constants/AIAConstants.cs | 2 ++ 400-SOURCECODE/AIAHTML5.API/Controllers/ClientController.cs | 13 +++++++++++++ 400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------- 400-SOURCECODE/AIAHTML5.Web/index.aspx | 2 +- 400-SOURCECODE/AIAHTML5.Web/index.aspx.cs | 9 +++++---- 5 files changed, 93 insertions(+), 19 deletions(-) diff --git a/400-SOURCECODE/AIAHTML5.API/Constants/AIAConstants.cs b/400-SOURCECODE/AIAHTML5.API/Constants/AIAConstants.cs index c950bd1..c203cd8 100644 --- a/400-SOURCECODE/AIAHTML5.API/Constants/AIAConstants.cs +++ b/400-SOURCECODE/AIAHTML5.API/Constants/AIAConstants.cs @@ -46,6 +46,8 @@ namespace AIAHTML5.API.Constants public const string SAVED_LAB_EXERCISE_NOT_FOUND = "Saved Lab Exercise not found."; public const string VALIDATED_CLIENT = "Valid Client."; public const string INVALID_CLIENT = "InValid Client."; + public const string MSG_NOT_AUTHORIZE_SITE_USER = "User is not authorized."; + public const string STATUS_OK = "ok"; public const string STATUS_NOT_OK = "notok"; diff --git a/400-SOURCECODE/AIAHTML5.API/Controllers/ClientController.cs b/400-SOURCECODE/AIAHTML5.API/Controllers/ClientController.cs index 2667aed..b36b232 100644 --- a/400-SOURCECODE/AIAHTML5.API/Controllers/ClientController.cs +++ b/400-SOURCECODE/AIAHTML5.API/Controllers/ClientController.cs @@ -36,7 +36,20 @@ namespace AIAHTML5.API.Controllers if (uerinfo != null) response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(uerinfo) }; else + { + //ser user = new User(); + //user.LoginFailureCauseId = AIAConstants.INVALID_CLIENT; + //dynamic userinfo = user; + //response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(userInfo) }; + 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) }; + + } return response; } diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js index e51ef7a..3cc127e 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js @@ -99,7 +99,10 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A status: null, accountNumber: null, edition: null, - urlReferer:null + urlReferer: null, + calsCreds: null, + userId: null, + password:null } $rootScope.userData; $rootScope.userModules; @@ -398,23 +401,78 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A $scope.ValidateClientSiteUrl = function () { - // urlParams = strIPAddress + "&" + strAccountNumber + "&" + strEdition + "&" + (strSiteReferer != "" && strSiteReferer != null ? strSiteReferer : ""); - var siteInfo = urlParams.split('&'); - $rootScope.siteUrlInfo.siteIP = siteInfo[0]; - $rootScope.siteUrlInfo.remoteIPAddress = siteInfo[1]; - $rootScope.siteUrlInfo.accountNumber = siteInfo[2]; - $rootScope.siteUrlInfo.edition = siteInfo[3]; - $rootScope.siteUrlInfo.urlReferer = siteInfo[4]; + var siteInfo = params.split('&'); - AuthenticationService.validateClientSite($rootScope.siteUrlInfo) - .then( + for (var i = 0; i < siteInfo.length; i++) + { + if (isCalsCredantial) { + var paramInfo = siteInfo[i].split('='); + if (paramInfo[0] == 'calsCredantial') { + + $rootScope.siteUrlInfo.calsCreds = paramInfo[1]; + } + else if (paramInfo[0] == 'username') { + + $rootScope.siteUrlInfo.username = paramInfo[1]; + } + else if (paramInfo[0] == 'password') { + + $rootScope.siteUrlInfo.password = paramInfo[1]; + } + + $rootScope.userInfo.username = $rootScope.siteUrlInfo.username; + $rootScope.userInfo.password = $rootScope.siteUrlInfo.password; + + $rootScope.AuthenticateUser($rootScope.userInfo); + + } + else{ + var paramInfo = siteInfo[i].split('='); + if (paramInfo[0] == 'siteIP') { + + $rootScope.siteUrlInfo.siteIP = paramInfo[1]; + } + else if (paramInfo[0] == 'accountNumber') { + + $rootScope.siteUrlInfo.accountNumber = paramInfo[1]; + } + else if (paramInfo[0] == 'edition') { + + $rootScope.siteUrlInfo.siteIP = paramInfo[1]; + } + else if (paramInfo[0] == 'urlReferer') { + + $rootScope.siteUrlInfo.siteIP = paramInfo[1]; + } + else if (paramInfo[0] == 'remoteIPAddress') { + + $rootScope.siteUrlInfo.remoteIPAddress = paramInfo[1]; + } + + AuthenticationService.validateClientSite($rootScope.siteUrlInfo) + .then( + + function (result) { + console.log(result); + if (result == LoginConstants.USER_NOT_FOUND) { + $rootScope.isVisibleLogin = true; + // alert(LoginMessageConstants.USER_OR_PASSWORD_INCORRECT); + $rootScope.errorMessage = LoginMessageConstants.INVALID_USER; + $("#messageModal").modal('show'); + } + }, + function (error) { } + ) + } + } + //$rootScope.siteUrlInfo.siteIP = siteInfo[0]; + //$rootScope.siteUrlInfo.remoteIPAddress = siteInfo[1]; + //$rootScope.siteUrlInfo.accountNumber = siteInfo[2]; + //$rootScope.siteUrlInfo.edition = siteInfo[3]; + //$rootScope.siteUrlInfo.urlReferer = siteInfo[4]; - function (result) { - }, - function (error) { } - ) } diff --git a/400-SOURCECODE/AIAHTML5.Web/index.aspx b/400-SOURCECODE/AIAHTML5.Web/index.aspx index bf50655..a7110f1 100644 --- a/400-SOURCECODE/AIAHTML5.Web/index.aspx +++ b/400-SOURCECODE/AIAHTML5.Web/index.aspx @@ -165,7 +165,7 @@ diff --git a/400-SOURCECODE/AIAHTML5.Web/index.aspx.cs b/400-SOURCECODE/AIAHTML5.Web/index.aspx.cs index 35b8a3f..3fa4e5f 100644 --- a/400-SOURCECODE/AIAHTML5.Web/index.aspx.cs +++ b/400-SOURCECODE/AIAHTML5.Web/index.aspx.cs @@ -18,6 +18,7 @@ namespace ADAM.AIA public string urlParams = "?"; public string test = ""; public bool isCalsCredantial = false; + protected void Page_Load(object sender, EventArgs e) { urlParams = "XYZ"; @@ -28,9 +29,9 @@ namespace ADAM.AIA { isCalsCredantial = true; - //urlParams = "?calsCredantial=" + Request.Form["calsCredantial"].ToString() + "&username=" + Request.Form["calsUsername"].ToString() + "&password=" + Request.Form["calsPassword"].ToString(); + urlParams = "calsCredantial=" + Request.Form["calsCredantial"].ToString() + "&username=" + Request.Form["calsUsername"].ToString() + "&password=" + Request.Form["calsPassword"].ToString(); //calsCredantialusername&password - urlParams = Request.Form["calsCredantial"].ToString() + "&username=" + Request.Form["calsUsername"].ToString() + "&password=" + Request.Form["calsPassword"].ToString(); + // urlParams = Request.Form["calsCredantial"].ToString() + "&username=" + Request.Form["calsUsername"].ToString() + "&password=" + Request.Form["calsPassword"].ToString(); } } @@ -99,11 +100,11 @@ namespace ADAM.AIA } //urlParams = "?siteIP=" + strIPAddress + "&status=" + intSiteId + "&accountNumber=" + strAccountNumber + "&edition=" + strEdition + "&urlReferer=" + (strSiteReferer != "" && strSiteReferer != null ? strSiteReferer : ""); - //urlParams = "siteIP=" + strIPAddress + "&accountNumber=" + strAccountNumber + "&edition=" + strEdition + "&urlReferer=" + (strSiteReferer != "" && strSiteReferer != null ? strSiteReferer : ""); + urlParams = "siteIP=" + strIPAddress + "&accountNumber=" + strAccountNumber + "&edition=" + strEdition + "&urlReferer=" + (strSiteReferer != "" && strSiteReferer != null ? strSiteReferer : "") + "&remoteIPAddress=" + remoteIPAddress; //For the ease of splitting desgined urlParms in the pattern of //urlParams = siteIP&accountNumber&remoteIPAddress&edition&urlReferer; without mentioning the variableName - urlParams = strIPAddress + "&" + remoteIPAddress+"&"+ strAccountNumber + "&" + strEdition + "&" + (strSiteReferer != "" && strSiteReferer != null ? strSiteReferer : ""); + // urlParams = strIPAddress + "&" + remoteIPAddress+"&"+ strAccountNumber + "&" + strEdition + "&" + (strSiteReferer != "" && strSiteReferer != null ? strSiteReferer : ""); } -- libgit2 0.21.4