mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-02-20 08:56:23 +00:00
2 lines
7.7 KiB
JavaScript
2 lines
7.7 KiB
JavaScript
!function(){"use strict";angular.module("SOGo.MainUI",["SOGo.Common","SOGo.Authentication"]);function e(e,o,s,r,a,n,i,t){var d=this;this.$onInit=function(){this.creds={username:o.cookieUsername,password:null,domain:null,rememberLogin:angular.isDefined(o.cookieUsername)&&0<o.cookieUsername.length},/\blanguage=/.test(o.location.search)&&(this.creds.language=o.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,s(function(){d.showLogin=!0;var e=window.location.search;let o=new URLSearchParams(e).get("token");0<window.location.pathname.indexOf("passwordRecoveryEmail")&&o?3===(e=(o=o.replace(/\//g,"")).split(".")).length&&(d.passwordRecovery.passwordRecoveryToken=o,e=JSON.parse(atob(e[1])),d.creds.username=e.username,d.creds.domain=e.domain,d.passwordRecovery.passwordRecoveryToken=o,d.passwordRecovery.passwordRecoveryMode="SecondaryEmail",d.passwordRecovery.passwordRecoveryEnabled=!0,d.loginState="passwordchange",d.showLogin=!1,t("loginContent")):d.retrievePasswordRecoveryEnabled()},100)},this.login=function(){return d.loginState="authenticating",n.login(d.creds).then(function(e){e.totpmissingkey?(d.loginState="totpcode",i("totpcode")):e.totpdisabled?(d.loginState="totpdisabled",d.cn=e.cn,d.url=e.url):(d.loginState="logged",d.cn=e.cn,d.url=e.url,s(function(){d.continueLogin()},1e3))},function(e){var o,s;d.loginState="error",e.error?d.errorMessage=e.error:0<e.grace?(d.loginState="passwordwillexpire",d.cn=e.cn,d.url=e.url,d.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?(s=86400<e.expire?(o=Math.round(e.expire/86400),l("days")):3600<e.expire?(o=Math.round(e.expire/3600),l("hours")):60<e.expire?(o=Math.round(e.expire/60),l("minutes")):(o=e.expire,l("seconds")),d.loginState="passwordwillexpire",d.cn=e.cn,d.url=e.url,d.errorMessage=l("Your password is going to expire in %{0} %{1}.",o,s)):e.passwordexpired&&(d.loginState="passwordchange",d.url=e.url)}),!1},this.restoreLogin=function(){d.showLogin=!1,"SecretQuestion"===d.passwordRecovery.passwordRecoveryMode?(t("loginContent"),d.passwordRecoveryInfo()):(delete d.creds.verificationCode,d.passwordRecoveryAbort())},this.continueLogin=function(){o.location.href===d.url?o.location.reload(!0):o.location.href=d.url},this.showAbout=function(e){function o(e){this.closeDialog=function(){e.hide()}}a.show({targetEvent:e,templateUrl:"aboutBox.html",controller:o,controllerAs:"about"}),o.$inject=["$mdDialog"]},this.changeLanguage=function(e){o.location.href=ApplicationBaseURL+"login?language="+this.creds.language},this.hello=function(e){return!1},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)))},this.changePassword=function(){n.changePassword(this.creds.username,this.creds.domain,this.passwords.newPassword,this.passwords.oldPassword,this.passwordRecovery.passwordRecoveryToken).then(function(e){d.loginState="message",d.url=e.url,d.errorMessage=l("The password was changed successfully.")},function(e){d.loginState="error",d.errorMessage=e})},this.passwordRecoveryInfo=function(){d.loginState="passwordrecovery",d.passwordRecovery.showLoader=!0,n.passwordRecovery(this.creds.username,this.creds.domain).then(function(e){d.passwordRecovery.passwordRecoveryMode=e.mode,"SecretQuestion"===e.mode?(d.passwordRecovery.passwordRecoveryQuestion=e.secretQuestionLabel,d.passwordRecovery.passwordRecoveryQuestionKey=e.secretQuestion):"SecondaryEmail"===e.mode?d.passwordRecovery.passwordRecoverySecondaryEmailText=l("A link will be sent to %{0}",e.obfuscatedRecoveryEmail):"Disabled"===e.mode&&(d.loginState="error",d.errorMessage=l("No password recovery method has been defined for this user")),d.passwordRecovery.showLoader=!1},function(e){d.loginState="error",d.errorMessage=e,d.passwordRecovery.showLoader=!1})},this.passwordRecoveryEmail=function(){d.passwordRecovery.showLoader=!0,n.passwordRecoveryEmail(this.creds.username,this.creds.domain,this.passwordRecovery.passwordRecoveryMode,this.passwordRecovery.passwordRecoveryMailDomain).then(function(){d.loginState="sendrecoverymail",d.passwordRecovery.showLoader=!1},function(e){d.loginState="error",d.errorMessage=e,d.passwordRecovery.showLoader=!1})},this.passwordRecoveryCheck=function(){d.passwordRecovery.showLoader=!0,n.passwordRecoveryCheck(this.creds.username,this.creds.domain,this.passwordRecovery.passwordRecoveryMode,this.passwordRecovery.passwordRecoveryQuestionKey,this.passwordRecovery.passwordRecoveryQuestionAnswer,this.passwordRecovery.passwordRecoveryMailDomain).then(function(e){"SecretQuestion"==d.passwordRecovery.passwordRecoveryMode?(d.passwordRecovery.passwordRecoveryToken=e,d.loginState="passwordchange"):"SecondaryEmail"==d.passwordRecovery.passwordRecoveryMode&&(d.loginState="sendrecoverymail"),d.passwordRecovery.showLoader=!1},function(e){d.loginState="error",d.errorMessage=e,d.passwordRecovery.showLoader=!1})},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,o.location.reload(!0)},this.usernameChanged=function(){this.passwordRecovery.passwordRecoveryLinkTimer&&clearTimeout(this.passwordRecovery.passwordRecoveryLinkTimer),this.passwordRecovery.passwordRecoveryLinkTimer=setTimeout(()=>{d.retrievePasswordRecoveryEnabled(),this.passwordRecovery.passwordRecoveryLinkTimer=null},2e3)},this.retrievePasswordRecoveryEnabled=function(){(this.creds.username||this.creds.domain)&&n.passwordRecoveryEnabled(this.creds.username,this.creds.domain).then(function(e){d.passwordRecovery.passwordRecoveryMailDomain=e,d.passwordRecovery.passwordRecoveryEnabled=!0},function(){d.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"],angular.module("SOGo.MainUI").controller("LoginController",e)}();
|
|
//# sourceMappingURL=Main.js.map
|