var loginDirectives,loginServices,loginapp,qs;angular.module("login.directives",[]);loginDirectives=angular.module("login.directives");loginDirectives.directive("focusMe",["$timeout","$parse",function(n,t){return{link:function(i,r,u){var f=t(u.focusMe);i.$watch(f,function(t){t===!0&&n(function(){r[0].focus()})})}}}]);angular.module("login.services",["ui.bootstrap"]);loginServices=angular.module("login.services");loginServices.factory("rememberMeService",function(){function n(n){for(var t,i,u=document.cookie.split("; "),r=0;r<u.length;r++)if(t=u[r].split("="),n===t[0]){i="";try{i=angular.fromJson(t[1])}catch(f){i=unescape(t[1])}return i}return null}return function(t,i){var r,f,u;if(arguments.length===1)return n(t);r=t+"=";typeof i=="object"?(f="",r+=typeof i.value=="object"?angular.toJson(i.value)+";":i.value+";",i.expires&&(u=new Date,u.setTime(u.getTime()+i.expires*864e5),f=u.toGMTString()),r+=i.session?"":"expires="+f+";",r+=i.path?"path="+i.path+";":"",r+=i.secure?"secure;":""):r+=i+";";document.cookie=r}});loginServices=angular.module("login.services");loginServices.service("modalService",["$modal","$window",function(n,t){var i={backdrop:!0,keyboard:!0,modalFade:!0,templateUrl:t.serverPaths.rootUrl+"/scripts/app/modal/modal.html"},r={closeButtonText:"Close",actionButtonText:"OK",headerText:"Proceed?",bodyText:"Perform This Action?"};this.showModal=function(n,t){return n||(n={}),n.backdrop="static",this.show(n,t)};this.show=function(t,u){var f={},e={};return angular.extend(f,i,t),angular.extend(e,r,u),f.controller||(f.controller=["$scope","$modalInstance",function(n,t){n.modalOptions=e;n.modalOptions.ok=function(n){t.close(n)};n.modalOptions.close=function(){t.dismiss("cancel")}}]),n.open(f).result}}]);loginServices=angular.module("login.services");loginServices.service("ConfigurationService",["$http","$rootScope","$q","$timeout","$log","fullUrl",function(n,t,i,r,u,f){var e=[];return e.ad={mode:"ad",name:"FDOT Active Directory Network",changePasswordDisclaimer:"Please contact the help desk to change your password if your password has expired.",canChangePassword:!0,canCreateNewAccount:!1,canResetPassword:!1,canUpdateAccount:!1,userIdExample:"CO\\AA123BB",userIdLabel:"Domain\\UserId",userIdPlaceholder:"Domain\\UserId",passwordRequirements:"8 character minimum; 1 upper, 1 lower, 1 number or special character",accountRegisterUrl:null,changePasswordUrl:f+"/login/ChangePasswordAD",externalAccountUpdateUrl:null,forgotPasswordUrl:null,loginUrl:f+"/login/loginad",securityQuestionsUrl:null,securityQuestionUrl:null,largeLogo:f+"/content/Images/AdWindowsmiddle128.png",mediumLogo:f+"/content/Images/AdWindowsmiddle64.png",userIdValidationExpression:/^([A-z][A-z0-9.-]+)\\((?! +$)[A-z0-9 ]+)$/,passwordValidationExpression:/(?=^.{8,64}$)((?=.*\d)(?=.*[A-Z])(?=.*[a-z])|(?=.*\d)(?=.*[^A-Za-z0-9])(?=.*[a-z])|(?=.*[^A-Za-z0-9])(?=.*[A-Z])(?=.*[a-z])|(?=.*\d)(?=.*[A-Z])(?=.*[^A-Za-z0-9]))^.*/},e.isa={mode:"isa",name:"Email - Internet Subscriber",changePasswordDisclaimer:"",canChangePassword:!0,canCreateNewAccount:!0,canResetPassword:!0,canUpdateAccount:!0,userIdExample:"example@example.com",userIdLabel:"Email Address",userIdPlaceholder:"Email Address",passwordRequirements:"8 character minimum; 1 upper, 1 lower, 1 number or special character",accountRegisterUrl:f+"/login/RegisterSubscriber",changePasswordUrl:f+"/login/ChangePasswordISA",externalAccountUpdateUrl:null,forgotPasswordUrl:f+"/login/ForgotPasswordISA",loginUrl:f+"/login/loginisa",securityQuestionsUrl:f+"/login/GetSecurityQuestions",securityQuestionUrl:f+"/login/GetSubscriberQuestion",largeLogo:f+"/content/Images/IsaEnvelope128.png",mediumLogo:f+"/content/Images/IsaEnvelope64.png",userIdValidationExpression:/[A-z0-9._%+-]+@[A-z0-9.-]+\.[A-z]{2,4}/,passwordValidationExpression:/(?=^.{8,64}$)((?=.*\d)(?=.*[A-Z])(?=.*[a-z])|(?=.*\d)(?=.*[^A-Za-z0-9])(?=.*[a-z])|(?=.*[^A-Za-z0-9])(?=.*[A-Z])(?=.*[a-z])|(?=.*\d)(?=.*[A-Z])(?=.*[^A-Za-z0-9]))^.*/},e.racf={mode:"racf",name:"RACF / Mainframe User",changePasswordDisclaimer:"",canChangePassword:!0,canCreateNewAccount:!1,canResetPassword:!1,canUpdateAccount:!1,userIdExample:"KNATCCR",userIdLabel:"RACF ID",userIdPlaceholder:"RACF ID",passwordRequirements:"8 characters",accountRegisterUrl:null,changePasswordUrl:f+"/login/ChangePasswordRACF",externalAccountUpdateUrl:null,forgotPasswordUrl:null,loginUrl:f+"/login/loginracf",securityQuestionsUrl:null,securityQuestionUrl:null,largeLogo:f+"/content/Images/RacfPhot1282.png",mediumLogo:f+"/content/Images/RacfPhot64.png",userIdValidationExpression:/([A-z0-9]){7,8}/,passwordValidationExpression:/([A-z0-9@#$]){8}/},{getConfiguration:function(t){var o=i.defer();return e?r(function(){t?o.resolve(e[t]):o.resolve(e)}):n.get(f+"/configuration").then(function(n){e=n.data;t?o.resolve(e[t]):o.resolve(e)},function(n){u.error(n);o.reject(n)}),o.promise},saveChanges:function(n){e=n;t.$broadcast("configuration:changed",e)}}}]);loginapp=angular.module("login",["ngRoute","ui.bootstrap","ui.mask","login.services","login.directives"]);qs=function(n){var r,t,i;if(n==="")return{};for(r={},t=0;t<n.length;++t)(i=n[t].split("="),i.length===2)&&(r[i[0]]=decodeURIComponent(i[1].replace(/\+/g," ")));return r}(window.location.search.substr(1).split("&"));loginapp.constant("authModes",qs.authModes?qs.authModes:"ad");loginapp.constant("realm",qs.wtrealm?qs.wtrealm:"");loginapp.constant("redirectUrl",qs.redirectUrl?qs.redirectUrl:window.serverPaths.rootUrl);loginapp.config(["$routeProvider","$windowProvider",function(n,t){var i=t.$get();n.when("/",{templateUrl:i.serverPaths.rootUrl+"scripts/app/login/login.html",controller:"LoginController",controllerAs:"ctrl"}).when("/changepassword",{templateUrl:i.serverPaths.rootUrl+"scripts/app/passwordchange/changepassword.html",controller:"PasswordChangeController",controllerAs:"ctrl"}).when("/forgotpassword",{templateUrl:i.serverPaths.rootUrl+"scripts/app/forgotpassword/forgotpassword.html",controller:"ForgotPasswordController",controllerAs:"ctrl"}).when("/register",{templateUrl:i.serverPaths.rootUrl+"scripts/app/register/registeraccount.html",controller:"RegisterAccountController",controllerAs:"ctrl",resolve:{securityQuestionsResponse:["$http",function(n){return n({method:"POST",url:i.serverPaths.securityQuestions})}]}}).when("/register/success",{templateUrl:i.serverPaths.rootUrl+"scripts/app/register/registeraccountsuccess.html",controller:"RegisterAccountController"}).otherwise({redirectTo:i.serverPaths.rootUrl})}]);loginapp.config(["$httpProvider",function(n){n.defaults.cache=!1;n.defaults.headers.get||(n.defaults.headers.get={});n.defaults.headers.get["If-Modified-Since"]="Mon, 26 Jul 1997 05:00:00 GMT";n.defaults.headers.get["Cache-Control"]="no-cache";n.defaults.headers.get.Pragma="no-cache"}]);loginapp.controller("LoginController",["$scope","$log","$http","$location","$routeParams","$window","authModes","redirectUrl","modalService","realm",function(n,t,i,r,u,f,e,o,s,h){var c=this;n.$on("modeChanged",function(){c.resetUsernameFields();c.resetPasswordFields();c.errorMessage="";c.focus=!0});c.focus=!1;c.busy=!1;c.login=function(){var e=n.activeMode.mode,u={username:null,password:null,realm:h,mode:e,returnurl:o,ipaddress:""},l;if(c.errorMessage="",e==="ad"){if(c.loginform.usernamead.$modelValue===""){c.errorMessage="ERROR: Please enter your "+n.activeMode.userIdLabel.toLowerCase()+".";return}if(c.loginform.usernamead.$invalid){c.errorMessage="ERROR: Please enter your "+n.activeMode.userIdLabel.toLowerCase()+". Example: "+n.activeMode.userIdExample;return}if(c.loginform.passwordad.$modelValue===""||c.loginform.passwordad.$invalid){c.errorMessage="ERROR: Please enter your active directory password.";return}u.username=c.loginform.usernamead.$modelValue;u.password=c.loginform.passwordad.$modelValue}else if(e==="racf"){if(c.loginform.usernameracf.$modelValue===""){c.errorMessage="ERROR: Please enter your "+n.activeMode.userIdLabel+".";return}if(c.loginform.usernameracf.$invalid){c.errorMessage="ERROR: Please enter your "+n.activeMode.userIdLabel+". Example: "+n.activeMode.userIdExample;return}if(c.loginform.passwordracf.$invalid||c.loginform.passwordracf.$modelValue===""){c.errorMessage="ERROR: Please enter your RACF password.";return}u.username=c.loginform.usernameracf.$modelValue;u.password=c.loginform.passwordracf.$modelValue}else if(e==="isa"){if(c.loginform.usernameisa.$invalid||c.loginform.usernameisa.$modelValue===""){c.errorMessage="ERROR: Please enter your "+n.activeMode.userIdLabel.toLowerCase()+". Example: "+n.activeMode.userIdExample;return}if(c.loginform.passwordisa.$invalid||c.loginform.passwordisa.$modelValue===""){c.errorMessage="ERROR: Please enter your internet subscriber password.";return}u.username=c.loginform.usernameisa.$modelValue;u.password=c.loginform.passwordisa.$modelValue}l={closeButtonText:"Cancel",actionButtonText:"Agree",headerText:"Terms of Service",bodyText:f.disclaimer};s.showModal({},l).then(function(){c.busy=!0;i({method:"POST",url:n.activeMode.loginUrl,data:u}).success(function(n){c.busy=!1;switch(n.type){case"success":n.description&&(c.errorMessage="WARNING: "+n.message);f.location=o;break;case"adminsuccess":n.description&&(c.errorMessage="WARNING: "+n.message);f.location=o;break;case"invalid":c.errorMessage="ERROR: "+n.message;e==="racf"&&u.username.split("@").length>1&&(c.errorMessage="ERROR: You must enter your RACF ID or select Internet Subscriber button to log in with an email address.");c.resetPasswordFields();break;case"expired":e!=="ad"&&(r.path("/changepassword"),r.search("userId",u.username),r.search("expired",!0));c.errorMessage="ERROR: "+n.message;c.resetPasswordFields();break;case"change":r.path("/changepassword");r.search("userId",u.username);r.search("required",!0);c.resetPasswordFields();c.errorMessage="ERROR: "+n.message;break;case"locked":c.errorMessage="ERROR: "+n.message;c.resetPasswordFields();break;case"error":c.errorMessage="ERROR: "+n.message;c.resetPasswordFields();break;default:$("body").html(n)}}).error(function(n,i){c.resetPasswordFields();t.error(n);c.busy=!1;i===409?(c.errorMessage="ERROR: You may only attempt login once every 3 seconds",c.resetPasswordFields()):(c.errorMessage="ERROR: Unexpected error. If issue persists, please notify the help desk.",c.resetPasswordFields())})})};c.resetPasswordFields=function(){c.passwordad="";c.passwordracf="";c.passwordisa=""};c.resetUsernameFields=function(){c.usernamead="";c.usernameisa="";c.usernameracf=""}}]);loginapp.controller("PasswordChangeController",["$scope","$log","$http","$location","$routeParams","$window","authModes","redirectUrl","modalService",function(n,t,i,r,u,f,e,o,s){var h=this;h.busy=!1;h.errorMessage=null;u.expired&&(h.errorMessage="ERROR: Your password is expired. Please set a new password.");u.required&&(h.errorMessage="ERROR: You are required to update your password before continuing.");h.changepassword=function(){if(h.errorMessage="",h.changepasswordform.username.$invalid||h.changepasswordform.username.$modelValue===""){h.errorMessage="ERROR: Please enter your "+n.activeMode.userIdLabel.toLowerCase().replace("racf","RACF")+".";return}if(h.changepasswordform.newpassword.$invalid||h.changepasswordform.newpassword.$modelValue===""){h.errorMessage="ERROR: Please enter a valid new "+n.activeMode.name.toLowerCase().replace("racf","RACF")+" password. Password should have "+n.activeMode.passwordRequirements+".";return}if(h.changepasswordform.newpasswordconfirm.$invalid||h.changepasswordform.newpasswordconfirm.$modelValue===""){h.errorMessage="ERROR: Please confirm your new password.";return}if(h.changepasswordform.oldpassword.$invalid||h.changepasswordform.oldpassword.$modelValue===""){h.errorMessage="ERROR: Please enter your old "+n.activeMode.name.toLowerCase().replace("racf","RACF")+" password.";return}if(h.changepasswordform.$invalid){n.errorMessage="ERROR: Change password data is invalid.";return}if(h.changepasswordform.newpassword.$modelValue!==h.changepasswordform.newpasswordconfirm.$modelValue){h.errorMessage="ERROR: Password and password confirmation do not match";return}var r={username:h.username,oldpassword:h.oldpassword,newpassword:h.newpassword,newpasswordconfirm:h.newpasswordconfirm};h.busy=!0;i({method:"POST",url:n.activeMode.changePasswordUrl,data:r}).success(function(n){h.busy=!1;switch(n.type){case"success":var t={backdrop:!0,keyboard:!0,modalFade:!0,templateUrl:f.serverPaths.rootUrl+"/scripts/app/modal/noclosemodal.html"};s.showModal(t,{closeButtonText:"Close",actionButtonText:"Continue",headerText:"Password Change",bodyText:"Your password has successfully changed."}).then(function(){f.location=o});break;case"invalid":h.errorMessage="ERROR: "+n.description;h.oldpassword="";break;case"error":h.errorMessage="ERROR: "+n.description;h.newpassword="";h.newpasswordconfirm="";break;default:h.errorMessage="ERROR: Unexpected response received from server.";h.newpassword="";h.newpasswordconfirm="";h.oldpassword=""}}).error(function(n,i){h.busy=!1;t.error(n);h.errorMessage=i===409?"ERROR: You may only attempt login once every 3 seconds":"ERROR: Unexpected error";h.oldpassword="";h.newpassword="";h.newpasswordconfirm="";h.username=""})}}]);loginapp.controller("ForgotPasswordController",["$scope","$http","$location","$routeParams","$log","$window","authModes","redirectUrl","modalService",function(n,t,i,r,u,f,e,o,s){var h=this;h.securityQuestion="What is your mother's maiden name?";h.busy=!1;h.step=1;h.sendPasswordReset=function(){if(h.errorMessage="",h.step1form.username.$invalid||h.step1form.username.$modelValue===""){h.errorMessage="ERROR: Please enter your "+n.activeMode.userIdLabel.toLowerCase().replace("racf","RACF")+".";return}n.busy=!0;t({method:"GET",url:n.activeMode.externalAccountUpdateUrl+"/requestPasswordReset/"+h.step1form.username.$modelValue}).then(function(){n.busy=!1;s.showModal({},{actionButtonText:"Ok",headerText:"Password Reset!",bodyText:"An email has been sent to your account with instructions on how to reset your password. Click OK to continue."}).then(function(){f.location=o})})};h.moveToNextStep=function(){if(h.errorMessage="",h.step1form.username.$invalid||h.step1form.username.$modelValue===""){h.errorMessage="ERROR: Please enter your "+n.activeMode.userIdLabel.toLowerCase().replace("racf","RACF")+".";return}n.busy=!0;var i={userid:h.step1form.username.$modelValue};t({method:"POST",url:n.activeMode.securityQuestionUrl,data:i}).success(function(n){if(h.busy=!1,n.message.length>0){h.errorMessage="ERROR: "+n.message;return}h.securityQuestion=n.securityQuestion;h.step=2}).error(function(n,t){h.busy=!1;u.error(n);h.errorMessage=t===409?"ERROR: You may only get question once every 3 seconds":"ERROR: Unexpected error"})};h.moveToFinalStep=function(){h.errorMessage="";h.busy=!0;var i={username:h.step1form.username.$modelValue,securityquestionresponse:h.step2form.securityQuestionResponse.$modelValue,securityQuestionSatisfied:!1};t({method:"POST",url:n.activeMode.forgotPasswordUrl,data:i}).success(function(n){h.busy=!1;switch(n.type){case"success":h.step=3;break;case"error":h.errorMessage="ERROR: "+n.description;break;case"locked":h.errorMessage="ERROR: "+n.description;break;default:h.errorMessage="ERROR: Unexpected response received from server."}}).error(function(n,t){h.busy=!1;h.errorMessage=t===409?"ERROR: You may only get question once every 3 seconds":"ERROR: Unexpected error"})};h.resetPassword=function(){if(h.errorMessage="",h.step3form.newpassword.$invalid||h.step3form.newpassword.$modelValue===""){h.errorMessage="ERROR: Please enter a valid new "+n.activeMode.name.toLowerCase().replace("racf","RACF")+" password. Password should have "+n.activeMode.passwordRequirements+".";return}if(h.step3form.newpasswordconfirm.$invalid||h.step3form.newpasswordconfirm.$modelValue===""){h.errorMessage="ERROR: Please confirm your new password.";return}if(n.busy=!0,h.step3form.newpassword.$modelValue!==h.step3form.newpasswordconfirm.$modelValue){h.errorMessage="ERROR:  Passwords do not match";return}var i={username:h.step1form.username.$modelValue,newpassword:h.step3form.newpassword.$modelValue,newpasswordconfirm:h.step3form.newpasswordconfirm.$modelValue,securityquestionresponse:h.step2form.securityQuestionResponse.$modelValue,securityQuestionSatisfied:!0};t({method:"POST",url:n.activeMode.forgotPasswordUrl,data:i}).success(function(n){h.busy=!1;switch(n.type){case"success":var t={backdrop:!0,keyboard:!0,modalFade:!0,templateUrl:f.serverPaths.rootUrl+"/scripts/app/modal/noclosemodal.html"};s.showModal(t,{closeButtonText:"Close",actionButtonText:"Continue",headerText:"Password Change",bodyText:"Your password has successfully changed."}).then(function(){f.location=o});break;case"error":h.errorMessage="ERROR: "+n.description;break;default:h.errorMessage="ERROR: Unexpected response received from server."}}).error(function(n,t){h.busy=!1;h.errorMessage=t===409?"ERROR: You may only attempt reset once every 3 seconds":"ERROR: Unexpected error"})}}]);loginapp.controller("RegisterAccountController",["$scope","$log","$http","$location","$routeParams","$window","securityQuestionsResponse","redirectUrl","modalService",function(n,t,i,r,u,f,e,o,s){var h=this;h.errorMessage=null;h.busy=!1;h.securityQuestionOptions=e.data;h.securityQuestion=h.securityQuestionOptions[0].questionId;h.register=function(){if(h.errorMessage="",h.registeraccountform.username.$modelValue===""||h.registeraccountform.username.$invalid){h.errorMessage="ERROR: Please enter your "+n.activeMode.userIdLabel.toLowerCase()+".";return}if(h.registeraccountform.agree.$invalid){h.errorMessage="ERROR: You must read and agree with the terms of use before creating an account.";return}if(h.registeraccountform.newpassword.$modelValue===""||h.registeraccountform.newpassword.$invalid){h.errorMessage="ERROR: Password must have "+n.activeMode.passwordRequirements.toLowerCase()+".";return}if(h.registeraccountform.newpasswordconfirm.$modelValue===""||h.registeraccountform.newpasswordconfirm.$invalid){h.errorMessage="ERROR: Password confirmation must have "+n.activeMode.passwordRequirements.toLowerCase()+".";return}if(h.registeraccountform.firstname.$modelValue===""||h.registeraccountform.firstname.$invalid){h.errorMessage="ERROR: Please enter a valid first name.";return}if(h.registeraccountform.lastname.$modelValue===""||h.registeraccountform.lastname.$invalid){h.errorMessage="ERROR: Please enter a valid last name.";return}if(h.registeraccountform.response.$modelValue===""||h.registeraccountform.response.$invalid){h.errorMessage="ERROR: Please enter a valid security question response.";return}if(h.registeraccountform.newpassword.$modelValue!==h.registeraccountform.newpasswordconfirm.$modelValue){h.errorMessage="ERROR: Password and password confirmation do not match";return}var u={firstname:h.registeraccountform.firstname.$modelValue,lastname:h.registeraccountform.lastname.$modelValue,username:h.registeraccountform.username.$modelValue,phone:h.registeraccountform.phone.$modelValue,newpassword:h.registeraccountform.newpassword.$modelValue,company:h.registeraccountform.company.$modelValue,securityquestion:h.registeraccountform.securityquestion.$modelValue,securityquestionresponse:h.registeraccountform.response.$modelValue};h.busy=!0;i({method:"POST",url:n.activeMode.accountRegisterUrl,data:u}).success(function(n){h.busy=!1;switch(n.type){case"success":var t={backdrop:!0,keyboard:!0,modalFade:!0,templateUrl:f.serverPaths.rootUrl+"/scripts/app/modal/noclosemodal.html"};s.showModal(t,{closeButtonText:"Close",actionButtonText:"Continue",headerText:"Account Creation",bodyText:"Your registration has been successfully submitted. Please check your email to verify your account."}).then(function(){r.path("/")});break;case"exists":h.errorMessage="ERROR: "+n.description;break;case"error":h.errorMessage="ERROR: "+n.description;break;default:h.errorMessage="ERROR: Unexpected response received from server."}}).error(function(n,i){h.busy=!1;t.error(n);h.errorMessage=i===409?"ERROR: You may only attempt registration once every 3 seconds":"ERROR: Unexpected error"})}}]);loginapp.controller("ShellController",["$scope","$location","$window","authModes","realm","rememberMeService","ConfigurationService",function(n,t,i,r,u,f,e){n.activeMode=null;n.possibleModes=[];n.rememberSelection=f("preferredStsModeChecked");n.loaded=!1;n.configuration=null;e.getConfiguration().then(function(u){if(n.configuration=u,angular.forEach(r.split(","),function(t){var r=n.configuration[t];t==="isa"&&(r.externalAccountUpdateUrl=i.serverPaths.isaUpdateUrl);r&&n.possibleModes.push(r)}),n.possibleModes.length===1?n.activeMode=n.possibleModes[0]:n.possibleModes.length===0&&(r="ad",n.possibleModes.push(n.configuration.ad),n.activeMode=n.possibleModes[0]),i.uiRoute)(i.uiRoute.indexOf("egister")>-1||i.uiRoute.indexOf("EGISTER")>-1)&&(n.activeMode=n.configuration.isa,n.$broadcast("modeChanged")),t.path(i.uiRoute);else if(f("preferredStsMode")){var e=f("preferredStsMode");e&&n.configuration[e]&&r.indexOf(e)>-1&&(n.activeMode=n.configuration[e],n.$broadcast("modeChanged"))}});n.switchToMode=function(i){n.rememberSelection?f("preferredStsMode",{value:i.mode,expires:!0}):f("preferredStsMode","");n.activeMode=i;t.path("/");n.$broadcast("modeChanged")};n.rememberMySelection=function(){n.rememberSelection?f("preferredStsModeChecked",{value:!1,expires:!0}):f("preferredStsModeChecked",{value:!0,expires:!0})};n.loaded=!0}])