mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-02-20 00:46:23 +00:00
2 lines
8.2 KiB
JavaScript
2 lines
8.2 KiB
JavaScript
!function(){"use strict";angular.module("SOGo.MainUI",["SOGo.Common","SOGo.Authentication"]);function e(e,s,o,r,a,i,n,t,d,c){var w=this;this.$onInit=function(){this.creds={username:s.cookieUsername,password:null,domain:null,rememberLogin:angular.isDefined(s.cookieUsername)&&0<s.cookieUsername.length},/\blanguage=/.test(s.location.search)&&(this.creds.language=s.language),this.loginState=!1,this.verificationCodePattern="\\d{6}",this.passwords={newPassword:null,newPasswordConfirmation:null,oldPassword:null,visible:!1},this.passwordRecovery={passwordRecoveryEnabled:!1,passwordRecoveryQuestionKey:null,passwordRecoveryQuestion:null,passwordRecoveryMode:null,passwordRecoveryQuestionAnswer:null,passwordRecoveryToken:null,passwordRecoveryLinkTimer:null,passwordRecoverySecondaryEmailText:null,passwordRecoveryMailDomain:null,showLoader:!1},this.showLogin=!1,o(function(){w.showLogin=!0;var e=window.location.search;let s=new URLSearchParams(e).get("token");0<window.location.pathname.indexOf("passwordRecoveryEmail")&&s?3===(e=(s=s.replace(/\//g,"")).split(".")).length&&(w.passwordRecovery.passwordRecoveryToken=s,e=JSON.parse(atob(e[1])),w.creds.username=e.username,w.creds.domain=e.domain,w.passwordRecovery.passwordRecoveryToken=s,w.passwordRecovery.passwordRecoveryMode="SecondaryEmail",w.passwordRecovery.passwordRecoveryEnabled=!0,w.loginState="passwordchange",t("loginContent")):w.retrievePasswordRecoveryEnabled(),0<document.querySelectorAll("*:autofill").length&&document.querySelectorAll("*:autofill").forEach(e=>{e.parentElement.classList.add("md-input-has-value")})},100)},this.login=function(){return w.loginState="authenticating",i.login(w.creds).then(function(e){e.totpmissingkey?(w.loginState="totpcode",n("totpcode")):e.totpdisabled?(w.loginState="totpdisabled",w.cn=e.cn,w.url=e.url):(w.loginState="logged",w.cn=e.cn,w.url=e.url,o(function(){w.continueLogin()},1e3))},function(e){var s,o;w.loginState="error",e.error?w.errorMessage=e.error:0<e.grace?(w.loginState="passwordwillexpire",w.cn=e.cn,w.url=e.url,w.passwordPolicy=e.userPolicies||[],w.errorMessage=l("You have %{0} logins remaining before your account is locked. Please change your password in the preference dialog.",e.grace)):0<e.expire?(o=86400<e.expire?(s=Math.round(e.expire/86400),l("days")):3600<e.expire?(s=Math.round(e.expire/3600),l("hours")):60<e.expire?(s=Math.round(e.expire/60),l("minutes")):(s=e.expire,l("seconds")),w.loginState="passwordwillexpire",w.cn=e.cn,w.url=e.url,w.errorMessage=l("Your password is going to expire in %{0} %{1}.",s,o)):(e.passwordexpired&&2==e.passwordexpired||e.passwordexpired)&&(w.loginState="passwordchange",w.passwordPolicy=e.userPolicies||[],w.url=e.url,w.passwordexpired=e.passwordexpired)}),!1},this.restoreLogin=function(){"SecretQuestion"===w.passwordRecovery.passwordRecoveryMode?t("loginContent"):delete w.creds.verificationCode,w.passwordRecoveryAbort()},this.continueLogin=function(){s.location.href===w.url?s.location.reload(!0):s.location.href=w.url},this.showAbout=function(e){function s(e){this.closeDialog=function(){e.hide()}}a.show({targetEvent:e,templateUrl:"aboutBox.html",controller:s,controllerAs:"about"}),s.$inject=["$mdDialog"]},this.changeLanguage=function(e){s.location.href=ApplicationBaseURL+"changeLanguage?language="+this.creds.language},this.canChangePassword=function(e){return this.passwords.newPasswordConfirmation&&this.passwords.newPasswordConfirmation.length&&this.passwords.newPassword!=this.passwords.newPasswordConfirmation?(e.newPasswordConfirmation.$setValidity("newPasswordMismatch",!1),!1):(e.newPasswordConfirmation.$setValidity("newPasswordMismatch",!0),!!(this.passwords.newPassword&&0<this.passwords.newPassword.length&&this.passwords.newPasswordConfirmation&&this.passwords.newPasswordConfirmation.length&&this.passwords.newPassword==this.passwords.newPasswordConfirmation&&(this.isInPasswordRecoveryMode()||!this.loginState&&this.passwords.oldPassword&&0<this.passwords.oldPassword.length||"passwordchange"==this.loginState&&this.passwords.oldPassword&&0<this.passwords.oldPassword.length)))},this.changePassword=function(){i.changePassword(this.creds.username,this.creds.domain,this.passwords.newPassword,this.passwords.oldPassword,this.passwordRecovery.passwordRecoveryToken).then(function(e){w.loginState="message",w.url=e.url,w.errorMessage=l("The password was changed successfully.")},function(e){c.show(c.simple().textContent(e).position(d.toastPosition).hideDelay(2e3))})},this.passwordRecoveryInfo=function(){w.loginState="passwordrecovery",w.passwordRecovery.showLoader=!0,i.passwordRecovery(this.creds.username,this.creds.domain).then(function(e){w.passwordRecovery.passwordRecoveryMode=e.mode,"SecretQuestion"===e.mode?(w.passwordRecovery.passwordRecoveryQuestion=e.secretQuestionLabel,w.passwordRecovery.passwordRecoveryQuestionKey=e.secretQuestion):"SecondaryEmail"===e.mode?w.passwordRecovery.passwordRecoverySecondaryEmailText=l("A link will be sent to %{0}",e.obfuscatedRecoveryEmail):"Disabled"===e.mode&&(w.loginState="error",w.errorMessage=l("No password recovery method has been defined for this user")),w.passwordRecovery.showLoader=!1},function(e){w.loginState="error",w.errorMessage=e,w.passwordRecovery.showLoader=!1})},this.passwordRecoveryEmail=function(){w.passwordRecovery.showLoader=!0,i.passwordRecoveryEmail(this.creds.username,this.creds.domain,this.passwordRecovery.passwordRecoveryMode,this.passwordRecovery.passwordRecoveryMailDomain).then(function(){w.loginState="sendrecoverymail",w.passwordRecovery.showLoader=!1},function(e){w.loginState="error",w.errorMessage=e,w.passwordRecovery.showLoader=!1})},this.passwordRecoveryCheck=function(){w.passwordRecovery.showLoader=!0,i.passwordRecoveryCheck(this.creds.username,this.creds.domain,this.passwordRecovery.passwordRecoveryMode,this.passwordRecovery.passwordRecoveryQuestionKey,this.passwordRecovery.passwordRecoveryQuestionAnswer,this.passwordRecovery.passwordRecoveryMailDomain).then(function(e){"SecretQuestion"==w.passwordRecovery.passwordRecoveryMode?(w.passwordRecovery.passwordRecoveryToken=e,w.loginState="passwordchange"):"SecondaryEmail"==w.passwordRecovery.passwordRecoveryMode&&(w.loginState="sendrecoverymail"),w.passwordRecovery.showLoader=!1},function(e){w.loginState="error",w.errorMessage=e,w.passwordRecovery.showLoader=!1})},this.isPasswordExpiredSecurity=function(){return this.passwordexpired&&2===this.passwordexpired},this.isInPasswordRecoveryMode=function(){return!!("SecretQuestion"==this.passwordRecovery.passwordRecoveryMode||"SecondaryEmail"==this.passwordRecovery.passwordRecoveryMode&&this.passwordRecovery.passwordRecoveryToken)},this.passwordRecoveryAbort=function(){this.passwords={newPassword:null,newPasswordConfirmation:null,oldPassword:null},this.loginState=!1,this.passwordRecovery.passwordRecoveryEnabled=!1,this.passwordRecovery.passwordRecoveryQuestion=null,this.passwordRecovery.passwordRecoveryMode=null,this.passwordRecovery.passwordRecoveryQuestionAnswer=null,this.passwordRecovery.passwordRecoveryToken=null,this.passwordRecovery.passwordRecoverySecondaryEmailText=null,this.passwordRecovery.passwordRecoveryMailDomain=null,this.passwordRecovery.showLoader=!1,s.location.reload(!0)},this.usernameChanged=function(){this.passwordRecovery.passwordRecoveryLinkTimer&&clearTimeout(this.passwordRecovery.passwordRecoveryLinkTimer),this.passwordRecovery.passwordRecoveryLinkTimer=setTimeout(()=>{w.retrievePasswordRecoveryEnabled(),this.passwordRecovery.passwordRecoveryLinkTimer=null},2e3)},this.retrievePasswordRecoveryEnabled=function(){(this.creds.username||this.creds.domain)&&i.passwordRecoveryEnabled(this.creds.username,this.creds.domain).then(function(e){w.passwordRecovery.passwordRecoveryMailDomain=e,w.passwordRecovery.passwordRecoveryEnabled=!0},function(){w.passwordRecovery.passwordRecoveryEnabled=!1})},this.changePasswordVisibility=function(){this.passwords.visible=!this.passwords.visible;var e=document.getElementById("passwordField");this.passwords.visible?(e.type="text",document.getElementById("password-visibility-icon").innerHTML="visibility_off"):(e.type="password",document.getElementById("password-visibility-icon").innerHTML="visibility")}}e.$inject=["$scope","$window","$timeout","Dialog","$mdDialog","Authentication","sgFocus","sgRippleClick","sgConstant","$mdToast"],angular.module("SOGo.MainUI").controller("LoginController",e)}();
|
|
//# sourceMappingURL=Main.js.map
|