{"version":3,"sources":["services/externalLoginService.js","controllers/loginPageController.js","controllers/loginController.js","controllers/passwordController.js"],"names":["angular","module","service","$http","$location","$window","__env","this","GetNonce","state","url","apiBaseUrl","encodeURIComponent","httpRequest","getExternalLoginUri","nonce","isGoogleEnabled","uri","ssoBaseUrl","ssoGooglePath","ssoOnlyPath","absUrl","split","externalLogin","token","data","method","withCredentials","headers","Content-Type","controller","$scope","$log","message","showErrorMessage","returnUrl","search","targetPage","pg","userEmail","email","pageHeader","referenceNumber","currentYear","Date","getFullYear","errorType","et","$watch","sessionStorage","getItem","value","closeErrorMessage","setErrorMessage","msg","isSso","isSsoEnabled","isLoggingIn","deleteCookie","name","document","cookie","domain","sessionCookieName","authCookieName","uniqueSessionCookieName","emailCookieName","changePassword","passwordForm","$pristine","newPassword","$setDirty","matchPassword","oldPassword","$valid","$parent","password","login","loginForm","username","Email","typedUsername","Password","typedPassword","errorMessage","then","onSuccess","onError","createCookie","key","secure","response","config","atob","indexOf","decodeURIComponent","slice","setResponse","sessionKey","secureCookies","uniqueSessionGuid","localStorage","setItem","portals","length","redirectUrl","baseUrl","adminConsoleUrl","portalHomeUri","portalTypeId","location","href","path","exceptionType","isInvalidEmail","messages","validationErrors","i","code","description","initiateExternalLogin","stateBeginSymbol","stateBeginIndex","btoa","currentState","id_token","reset","resetForm","typedEmail","replace","page","encodeURI"],"mappings":"AAKAA,QAAAC,OAAA,OAAAC,QAAA,iBAAA,QAAA,YAAA,UAAA,QAAA,SAAAC,EAAAC,EAAAC,EAAAC,GASAC,KAAAC,SAAA,SAAAC,GACA,GAAAC,GAAAJ,EAAAK,WAAA,kBAKA,OAJAF,KACAC,GAAAE,mBAAAH,IAGAF,KAAAM,YAAAH,EAAA,MAAA,MAAA,IAYAH,KAAAO,oBAAA,SAAAL,EAAAM,EAAAC,GAEA,GAAAC,GAAAX,EAAAY,UAeA,OAbAD,IADAD,EACAV,EAAAa,cAEAb,EAAAc,YAIAH,GAAA,8HADAL,mBAAAR,EAAAi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service to help with the external login procedures\n * \n * @class externalLogin\n */\nangular.module('app').service('externalLogin', ['$http', '$location', '$window', '__env', function ($http, $location, $window, __env) {\n\n /**\n * Calls the login API to generate a nonce value\n * \n * @function GetNonce\n * @param {string} state - State to pass to the login server\n * @returns {Object} - returns a Http promise\n */\n this.GetNonce = function(state) {\n var url = __env.apiBaseUrl + \"/login/external/\";\n if (state) {\n url = url + encodeURIComponent(state);\n }\n\n return this.httpRequest(url, 'get', null, true);\n };\n\n /**\n * Get the uri to the sso login server\n * \n * @function getExternalLoginUri\n * @param {string} state - State to send to the login server\n * @param {string} nonce - nonce value to pass to the login server - Should be the value generated by the login API\n * @param {bool} isGoogleEnabled - If Google authentication is enabled\n * @returns {string} - Uri to the login server, with a populated query string\n */\n this.getExternalLoginUri = function(state, nonce, isGoogleEnabled)\n {\n var uri = __env.ssoBaseUrl;\n if (isGoogleEnabled) {\n uri += __env.ssoGooglePath;\n } else {\n uri += __env.ssoOnlyPath;\n }\n\n var redirectUri = encodeURIComponent($location.absUrl().split('?')[0] + \"?\");\n uri += '/connect/authorize?acr_values=idp:Google&client_id=implicitclient&response_type=id_token&scope=openid%20email&redirect_uri=' +\n redirectUri +\n '&response_mode=fragment&state=' +\n state +\n '&nonce=' +\n nonce; \n\n return uri;\n }\n\n /**\n * Call the login API to login with a 3rd party token\n * \n * @function externalLogin\n * @param {string} state - State that was used when generating the nonce value\n * @param {string} token - Token coming from the login server\n * @returns {Object} - Angular Http promise\n */\n this.externalLogin = function(state, token) {\n\n var url = __env.apiBaseUrl + '/login/external'\n\n var data = { 'state': state, 'token': token };\n\n return this.httpRequest(url, 'post', data, true);\n }\n\n /**\n * Helper function to generate a REST request\n * \n * @param {string} url - Url to query\n * @param {string} method - Method to use (PUT, POST, ...)\n * @param {Object} data - Object to send as the body of the request\n * @param {bool} withCredentials - Whether we should send credentials (aka cookies) with the call\n * @returns {Object} - Angular HTTP promise\n */\n this.httpRequest = function(url, method, data, withCredentials) {\n return $http({\n withCredentials: withCredentials,\n url: url,\n data: data,\n method: method,\n headers: {\n 'Content-Type': 'application/json'\n }\n });\n };\n\n}]);\n\n","// Login Module\nangular.module('app').controller('loginPageController', ['$scope', '$location', '$log', '$window', function ($scope, $location, $log, $window) {\n\t///////////////////////////////////////////////////////////////////////////\n\t// Members\n ///////////////////////////////////////////////////////////////////////////\t\n\t$scope.message = '';\t\n\t$scope.showErrorMessage = false;\n\t$scope.returnUrl = $location.search().returnUrl;\n\t$scope.targetPage = typeof($location.search().pg) == 'undefined' ? 'home.asp' : $location.search().pg;\n\t$scope.userEmail = $location.search().email;\n\t$scope.pageHeader = \"Please log in to continue.\";\t\n\t$scope.referenceNumber = null;\n\t$scope.currentYear = new Date().getFullYear();\n\t$scope.errorType = $location.search().et;\n\n\t///////////////////////////////////////////////////////////////////////////\n\t// Functions\n\t///////////////////////////////////////////////////////////////////////////\n\t\n\t/**\n\t * Watch for changes in the Assent Context Key\n\t */\n\t$scope.$watch(function () {\n\t\treturn $window.sessionStorage.getItem('assentContextKey')\n\t}, function (value) {\n\t\t$scope.referenceNumber = value;\n\t});\n\n\t/**\n\t * Closes and resets error message\n\t *\n\t * @function\n\t */\n\t$scope.closeErrorMessage = function() {\n\t\t// hide the message\n\t\t$scope.showErrorMessage = false;\n\n\t\t// set the message to empty string\n\t\t$scope.message = '';\n\t};\n\n\t\n\t/**\n\t * Sets and displays error message\n\t *\n\t * @function\n\t * @param { string } msg - The message to display\n\t */\n\t$scope.setErrorMessage = function(msg) {\n\t\t// set the message \n\t\t$scope.message = '
' + msg + '
';\n\n\t\t// show the message\n\t\t$scope.showErrorMessage = true;\t\t\n\t};\n}]);","/**\n * Constructor for loginController\n *\n * @class loginController\n * @param { Object } $scope - The scope of the controller.\n * @param { Object } $http - The Angular $http service.\n * @param { Object } $location - The Angular $location service.\n * @param { Object } externalLogin - The external login service.\n * @param { Object } __env - The environment configuration.\n */\n\nangular.module(\"app\").controller(\"loginController\", [\n \"$scope\",\n \"$http\",\n \"$location\",\n \"$window\",\n \"externalLogin\",\n \"__env\",\n \"$log\",\n function($scope, $http, $location, $window, externalLogin, __env, $log) {\n $scope.isSso = __env.isSsoEnabled;\n $scope.isGoogleEnabled = __env.isGoogleEnabled;\n $scope.isLoggingIn = false;\n\n /* delete cookie by name */\n $scope.deleteCookie = function(name) {\n document.cookie =\n name +\n \"=;domain=\" +\n __env.domain +\n \";expires=Thu, 01 Jan 1970 00:00:01 GMT\";\n };\n\n // when navigating to this page, delete the old cookies for logout\n $scope.deleteCookie(__env.sessionCookieName);\n $scope.deleteCookie(__env.authCookieName);\n $scope.deleteCookie(__env.uniqueSessionCookieName);\n $scope.deleteCookie(__env.emailCookieName);\n\n /**\n * Handles password reset event from the front page and prepares the http request for\n * resetting password\n *\n * @function\n */\n $scope.changePassword = function() {\n if ($scope.passwordForm.$pristine) {\n $scope.passwordForm.newPassword.$setDirty();\n $scope.passwordForm.matchPassword.$setDirty();\n $scope.passwordForm.oldPassword.$setDirty();\n\n return;\n }\n\n if ($scope.newPassword !== $scope.matchPassword) {\n $scope.setErrorMessage(\"Passwords must match to be updated.\");\n return;\n }\n\n // make sure there are no errors\n if ($scope.passwordForm.$valid) {\n var url = __env.apiBaseUrl + \"login/password\";\n var errorMessage =\n \"Invalid Request. Please contact your Account Manager.\";\n var data = {\n email: $scope.$parent.userEmail,\n password: $scope.oldPassword,\n newPassword: $scope.newPassword\n };\n var method = \"put\";\n\n $scope.httpRequest(url, method, errorMessage, data);\n }\n };\n\n /**\n * Handles login event from the front page and prepares the http request for login\n *\n * @function\n */\n $scope.login = function() {\n // if the user hasn't entered anything, show the errors\n if ($scope.loginForm.$pristine) {\n $scope.loginForm.username.$setDirty();\n $scope.loginForm.password.$setDirty();\n\n return;\n }\n\n // make sure there are no errors\n if ($scope.loginForm.$valid) {\n // set the username and password to pass\n var data = {\n Email: $scope.typedUsername,\n Password: $scope.typedPassword\n };\n var url = __env.apiBaseUrl + \"login/password\";\n var errorMessage = \"The credentials supplied are invalid.\";\n var method = \"post\";\n $scope.$parent.userEmail = $scope.typedUsername;\n $scope.httpRequest(url, method, errorMessage, data);\n $scope.isLoggingIn = true;\n }\n };\n\n /**\n * Sends Http request to server\n * on success, navigates to desired page or to home page\n *\n * @method httpRequest\n * @param { string } url - url to call\n * @param { string } method - The HTTP method to use\n * @param { string } errorMessage - message to display on error\n * @param { Object } data - data to post\n */\n $scope.httpRequest = function(url, method, errorMessage, data) {\n $http({\n url: url,\n data: data,\n method: method,\n headers: {\n \"Content-Type\": \"application/json\"\n }\n }).then($scope.onSuccess, $scope.onError);\n };\n\n /**\n * Creates the cookie used for authentication\n *\n * @function createCookie\n * @param { string } key - The unique key of the session\n * @param { string } secure - If true the cookie is set with the secure flag\n */\n $scope.createCookie = function(name, key, secure) {\n // Domain -- This should likely be .dev.assentcompliance.com for dev instances instead of a catch-all\n\n if (name && key) {\n // cookie expiration disabled temporarily until session extension extends cookie\n // ACP-7111\n document.cookie = name + \"=\" + key + \";domain=\" + __env.domain + \";\" + (secure ? \"secure;\" : \"\");\n }\n };\n\n /**\n * Callback to process a successful call to the login API\n *\n * @function onSuccess\n * @param { Object } response - The response object coming from the $http promise\n * @param { Object } response.data - The data coming out of the login API\n * @param { string } response.data.sessionKey - Key of the session\n * @param { Object[] } response.data.portals - List of portals the use has access to\n * @param { string } portals[].portalHomeUri - Uri of the portal's home page\n */\n $scope.onSuccess = function(response) {\n if (\n typeof response.config.data.state !== \"undefined\" &&\n response.config.data.state !== \"undefined\" &&\n response.config.data.state !== 'null'\n ) {\n var state = atob(response.config.data.state);\n\n //replacing startswith with indexof === 0 due to ie11 compatability\n if (state.indexOf(\"http\") === 0) {\n $scope.returnUrl = decodeURIComponent(state);\n } else if (state.indexOf(\"returnUrl\") === 0) {\n $scope.returnUrl = decodeURIComponent(state).slice(\n state.indexOf(\"=\") + 1\n );\n } else {\n $scope.targetPage = state;\n }\n }\n\n $scope.isLoggingIn = false;\n $scope.setResponse(response);\n\n // create session cookie\n $scope.createCookie(\n __env.sessionCookieName,\n response.data.sessionKey,\n __env.secureCookies\n );\n\n // create email cookie\n $scope.createCookie(\n __env.emailCookieName,\n response.data.email,\n __env.secureCookies\n );\n\n // create JWT cookie\n $scope.createCookie(\n __env.authCookieName,\n response.data.token,\n __env.secureCookies\n );\n\n // create unique session cookie\n $scope.createCookie( \n __env.uniqueSessionCookieName,\n response.data.uniqueSessionGuid,\n __env.secureCookies\n );\n\n // clear the supplier filters as they login\n localStorage.setItem(\"supplierFilters\", \"{}\");\n\n var portals = response.data.portals;\n\n if (!portals || portals.length <= 0) {\n $scope.setErrorMessage(\n \"You don't seem to have permissions for anything. Please contact your site administrator\"\n );\n\n return;\n }\n\n var redirectUrl;\n var returnUrlProvided = typeof $scope.returnUrl !== \"undefined\";\n if (returnUrlProvided) {\n redirectUrl = $scope.returnUrl;\n } else {\n var baseUrl =\n portals.length > 1 ? __env.adminConsoleUrl : portals[0].portalHomeUri;\n\n var delimeter = baseUrl === __env.adminConsoleUrl ? \"/#/?pg=\" : \"/\";\n\n var AcmPortalTypeId = 2;\n var targetPage =\n portals.length !== 1 || portals[0].portalTypeId === AcmPortalTypeId\n ? $scope.targetPage\n : \"\";\n\n redirectUrl = baseUrl + delimeter + targetPage;\n }\n\n document.location.href = redirectUrl;\n };\n\n /**\n * Callback to process an unsuccesful attempt at login in\n *\n * @function onError\n * @param { Object } response - Response object coming out of the Angular $http promise\n * @param { Object } response.data - The data coming out of the login API\n *\n */\n $scope.onError = function(response) {\n $scope.setResponse(response);\n $scope.isLoggingIn = false;\n if (\n response.data &&\n response.data.message === \"User must change password\"\n ) {\n errorMessage = \"You must change your password\";\n $location.path(\"/login/password\");\n } else if (\n response.data &&\n response.data.exceptionType ===\n \"CoreAuthentication.Exceptions.UserLockedOutException\"\n ) {\n errorMessage =\n \"Your account is currently locked. Please contact your Account Administrator for assistance.\";\n $location.path(\"/login\");\n } else if (\n response.data &&\n response.data.exceptionType ===\n \"CoreAuthentication.Exceptions.ValidationErrorException\"\n ) {\n var isInvalidEmail = false;\n errorMessage = \"\";\n $location.path(\"/login/password\");\n }\n } else if (\n response.data &&\n response.data.exceptionType ===\n \"CoreAuthentication.Exceptions.UserDeactivatedException\"\n ) {\n errorMessage =\n \"Your login has expired. Email customersupport@assentcompliance.com to create a support ticket and re-enable your account for this Information System.\";\n $location.path(\"/login\");\n } else {\n errorMessage =\n \"Unauthorized Login. Please try again or contact your Account Administrator for assistance.\";\n $location.path(\"/login\");\n }\n\n $scope.setErrorMessage(errorMessage);\n };\n\n /**\n * Initiates the external login procedures by calling the login API to get a nonce value.\n * If successful, redirects to the SSO server\n * Otherwise sets an error message.\n *\n * @function initiateExternalLogin\n */\n $scope.initiateExternalLogin = function() {\n // need to strip the page state from the url\n var stateBeginSymbol = $location.url().indexOf(\"http\", 1) > 0 ? \"?\" : \"=\";\n var stateBeginIndex = $location.url().indexOf(stateBeginSymbol) + 1;\n var state =\n stateBeginIndex > 0\n ? btoa($location.url().slice(stateBeginIndex))\n : \"null\";\n\n externalLogin.GetNonce(state).then(\n function(response) {\n $scope.setResponse(response);\n var nonce = response.data.nonce;\n var currentState = response.data.state;\n\n var uri = externalLogin.getExternalLoginUri(\n currentState,\n nonce,\n $scope.isGoogleEnabled\n );\n\n $window.location.href = uri;\n },\n function(response) {\n if (\n response.data &&\n response.data.exceptionType ===\n \"CoreAuthentication.Exceptions.UserDeactivatedException\"\n ) {\n errorMessage =\n \"Your login has expired. Email customersupport@assentcompliance.com to create a support ticket and re-enable your account for this Information System.\";\n $location.path(\"/login\");\n } else {\n errorMessage =\n \"Unauthorized Login. Please try again or contact your Account Administrator for assistance.\";\n $location.path(\"/login\");\n }\n $scope.setResponse(response);\n $scope.setErrorMessage(errorMessage);\n }\n );\n };\n\n /**\n * Sets the response property of the $scope object,\n *\n * @function setResponse\n * @param { Object } response - Response object coming out of the Angular $http promise\n */\n $scope.setResponse = function(response) {\n $scope.response = response;\n };\n\n // processing error types on the query string\n if (typeof $scope.errorType !== \"undefined\") {\n var errorType = $scope.errorType;\n $location.search(\"et\", null);\n if (errorType === \"timeout\") {\n var timeoutErrorMessage =\n \"You have been logged out of your account due to inactivity. Please log in again.\";\n $scope.setErrorMessage(timeoutErrorMessage);\n }\n }\n\n // processing external login information on the query string\n var search = $location.search();\n var state = search.state;\n var token = search.id_token;\n\n if (state && token) {\n externalLogin\n .externalLogin(state, token)\n .then($scope.onSuccess, function(response) {\n if (\n response.data &&\n response.data.exceptionType ===\n \"CoreAuthentication.Exceptions.UserDeactivatedException\"\n ) {\n errorMessage =\n \"Your login has expired. Email customersupport@assentcompliance.com to create a support ticket and re-enable your account for this Information System.\";\n $location.path(\"/login\");\n } else {\n errorMessage =\n \"Unauthorized Login. Please try again or contact your Account Administrator for assistance.\";\n $location.path(\"/login\");\n }\n $scope.setResponse(response);\n $scope.setErrorMessage(errorMessage);\n $location.search({});\n });\n }\n }\n]);\n","angular.module('app').controller('passwordController', ['$scope', '$http', '$location', '__env', function($scope, $http, $location, __env){\n\n\t\n\t/**\n\t * Handles password reset event from the front page and prepares the http request for \n\t * resetting password\n\t * sends the http request that should email the user a new password\n\t *\n\t * @function\n\t */\n\t$scope.reset = function() {\n\t\tif($scope.resetForm.$pristine) {\n\n\t\t\t$scope.resetForm.email.$setDirty();\n\t\t\t\n\t\t\treturn;\n\t\t} \t\t\n\n\t\t// make sure there are no errors\n\t\tif($scope.resetForm.$valid){\n\n\t\t\tvar email = $scope.typedEmail.replace('+', ' ');\n\t\t\tvar data = { 'email': $scope.typedEmail, 'page': $scope.targetPage };\n\n\t\t\t$http({\n\t\t\t\turl: __env.apiBaseUrl + 'login/' + encodeURI($scope.typedEmail) + '/password/reset',\n\t\t\t\tdata: data,\n\t\t\t\tmethod: 'put',\n\t\t\t\theaders: {\n\t\t\t\t\t'Content-Type': 'application/json'\n\t\t\t\t}\n\t\t\t}).then(\n\t\t\tfunction successCallback(response){\n\t\t\t\t//console.log('ok');\n\t\t\t\t// setup the session\n\t\t\t\t$scope.setErrorMessage('If an account exists, you should receive an email with your credentials.');\n\t\t\t\t$location.path('/login');\n\n\t\t\t},\n\t\t\tfunction errorCallback(response) {\n\t\t\t\t$scope.setErrorMessage('Invalid Request. Please contact your Account Manager.');\n\t\t\t});\n\t\t}\n\t};\n\n\t\n}]);"]}