!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common"),require("@angular/router"),require("@nebular/auth"),require("@ngx-translate/core"),require("@nebular/theme"),require("@angular/forms"),require("rxjs"),require("rxjs/operators"),require("@angular/common/http"),require("jsencrypt")):"function"==typeof define&&define.amd?define("ge-admin-auth",["exports","@angular/core","@angular/common","@angular/router","@nebular/auth","@ngx-translate/core","@nebular/theme","@angular/forms","rxjs","rxjs/operators","@angular/common/http","jsencrypt"],t):t((e=e||self)["ge-admin-auth"]={},e.ng.core,e.ng.common,e.ng.router,e.auth,e.core$1,e.theme,e.ng.forms,e.rxjs,e.rxjs.operators,e.ng.common.http,e.jsencrypt)}(this,(function(e,t,r,n,s,o,a,i,l,u,c,g){"use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */var d=function(e,t){return(d=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function p(e,t){function r(){this.constructor=e}d(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var h={"与第一次输入不符合":"与第一次输入不符合.","修改密码":"修改密码","密码":"密码","密码:":"密码:","密码是必填的":"密码是必填的","密码规则提示":"密码应该包含 最小长度 {{minLength}} 最大长度 {{maxLength}} 个字符","您好,欢迎使用":"您好,欢迎使用","成功!":"成功!","新密码":"新密码","新密码:":"新密码:","新密码是必填的!":"新密码是必填的!","旧密码:":"旧密码:","旧密码是必填的!":"旧密码是必填的","登出提示":"正在登出, 请等待...","登录":"登录","确认密码":"确认密码","确认密码:":"确认密码:","确认密码是必填的!":"确认密码是必填的!","请设置您的新密码":"请设置您的新密码","账户":"账户","账户:":"账户:","账户是必填的":"账户是必填的","错误!":"错误!"},f={"与第一次输入不符合":"與第一次輸入不符合.","修改密码":"更改密碼","密码":"密碼","密码:":"密碼:","密码是必填的":"必須填寫密碼","密码规则提示":"密碼應該包含 最小長度 {{minLength}} 最大長度 {{maxLength}} 個字符","您好,欢迎使用":"您好,歡迎使用","成功!":"成功!","新密码":"新密碼","新密码:":"新密碼:","新密码是必填的!":"必須填寫新密碼","旧密码:":"舊密碼:","旧密码是必填的!":"必須填寫舊密碼","登出提示":"正在登出, 請稍候⋯","登录":"登入","确认密码":"確認密碼","确认密码:":"確認密碼:","确认密码是必填的!":"必須填寫確認密碼","请设置您的新密码":"請設置您的新密碼","账户":"賬戶","账户:":"賬戶:","账户是必填的":"必須填寫賬戶","错误!":"錯誤!"},m=new t.InjectionToken("AUTH_DEFAULT_LANG"),w=function(){function e(e,t){this._translate=e,this._translate.setTranslation("zh-cn",h),this._translate.setTranslation("zh-hk",f),this._translate.setDefaultLang(t||"zh-cn"),this._translate.use(t||"zh-cn")}return e.prototype.setTranslate=function(e){this._translate.use(e)},e.decorators=[{type:t.Injectable}],e.ctorParameters=function(){return[{type:o.TranslateService},{type:String,decorators:[{type:t.Optional},{type:t.Inject,args:[m]}]}]},e}();function y(e,t,r){var n,s;void 0===e&&(e={});var o=t.split("."),a=e;try{for(var i=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(o),l=i.next();!l.done;l=i.next()){var u=l.value;if(!a)break;a=a[u]}}catch(e){n={error:e}}finally{try{l&&!l.done&&(s=i.return)&&s.call(i)}finally{if(n)throw n.error}}return void 0===a?r:a}var b=function(){function e(e,t,r,n,s){void 0===r&&(r={}),this.service=e,this.langService=t,this.options=r,this.cd=n,this.router=s,this.redirectDelay=0,this.showMessages={},this.strategy="",this.errors=[],this.messages=[],this.user={},this.submitted=!1,this.socialLinks=[],this.rememberMe=!1,this.redirectDelay=this.getConfigValue("forms.login.redirectDelay"),this.showMessages=this.getConfigValue("forms.login.showMessages"),this.strategy=this.getConfigValue("forms.login.strategy"),this.socialLinks=this.getConfigValue("forms.login.socialLinks"),this.rememberMe=this.getConfigValue("forms.login.rememberMe")}return e.prototype.login=function(){var e=this;this.errors=[],this.messages=[],this.submitted=!0,this.service.authenticate(this.strategy,this.user).subscribe((function(t){e.submitted=!1,t.isSuccess()?e.messages=t.getMessages():e.errors=t.getErrors();var r=t.getRedirect();r&&setTimeout((function(){return e.router.navigateByUrl(r)}),e.redirectDelay),e.cd.detectChanges()}))},e.prototype.getConfigValue=function(e){return y(this.options,e,null)},e.decorators=[{type:t.Component,args:[{selector:"auth-login",template:'

登录

\r\n

您好,欢迎使用

\r\n\r\n\r\n

错误!

\r\n \r\n
\r\n\r\n\r\n

成功!

\r\n \r\n\r\n\r\n
\r\n
\r\n \r\n \r\n \r\n

\r\n\r\n

\r\n
\r\n
\r\n\r\n
\r\n \r\n \r\n \r\n

\r\n\r\n

\r\n

\r\n 密码应该包含 最小长度 {{ getConfigValue(\'forms.validation.password.minLength\') }} 最大长度\r\n {{ getConfigValue(\'forms.validation.password.maxLength\') }}\r\n 个字符\r\n

\r\n
\r\n
\r\n\r\n \x3c!--
--\x3e\r\n \x3c!--记住账号--\x3e\r\n \x3c!--<!–Forgot Password?–>--\x3e\r\n \x3c!--
--\x3e\r\n\r\n \r\n \r\n\r\n\r\n\x3c!----\x3e\r\n\r\n\x3c!--
--\x3e\r\n\x3c!--Don\'t have an account? Register--\x3e\r\n\x3c!--
--\x3e\r\n',changeDetection:t.ChangeDetectionStrategy.OnPush}]}],e.ctorParameters=function(){return[{type:s.NbAuthService},{type:w},{type:void 0,decorators:[{type:t.Inject,args:[s.NB_AUTH_OPTIONS]}]},{type:t.ChangeDetectorRef},{type:n.Router}]},e}(),v=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.baseEndpoint="/api/auth/",t.getPublicKey={endpoint:"getPublicKey",method:"get"},t.login={alwaysFail:!1,endpoint:"login",method:"post",redirect:{success:"/",failure:null},defaultErrors:["未知错误!"],defaultMessages:["You have been successfully logged in."]},t.createUser={endpoint:"createUser",method:"post",defaultErrors:["未知错误!"]},t.updatePasswordForAdmin={endpoint:"updatePasswordForAdmin",method:"patch",defaultErrors:["未知错误!"]},t.register={alwaysFail:!1,endpoint:"register",method:"post",redirect:{success:"/",failure:null},defaultErrors:["Something went wrong, please try again."],defaultMessages:["You have been successfully registered."]},t.requestPass={endpoint:"request-pass",method:"post",redirect:{success:"/",failure:null},defaultErrors:["Something went wrong, please try again."],defaultMessages:["Reset password instructions have been sent to your email."]},t.resetPass={endpoint:"updateUserPassword",method:"patch",redirect:{success:"/",failure:null},defaultErrors:["未知错误."],defaultMessages:["Your password has been successfully changed."]},t.logout={alwaysFail:!1,endpoint:"logout",method:"delete",redirect:{success:"/",failure:null},defaultErrors:["Something went wrong, please try again."],defaultMessages:["You have been successfully logged out."]},t.errors={key:"messager",getter:function(e,t,r){return[y(t.error,r.errors.key,r[e].defaultErrors)]}},t.messages={key:"messager",getter:function(e,t,r){return[y(t.body,r.messages.key,!1)]}},t.success={key:"success",getter:function(e,t,r){return y(t.body,r.success.key,r[e].defaultMessages)}},t}return p(t,e),t}(s.NbAuthStrategyOptions),x=new v,P=function(e){this.message=e},L=function(e){function r(t,r){var n=e.call(this)||this;return n.http=t,n.route=r,n.defaultOptions=x,n}return p(r,e),r.setup=function(e){return[r,e]},r.prototype.authenticate=function(e){var t=this,r=this.getOption("login.method"),n=this.getActionEndpoint("login");this.getOption("login.requireValidToken");return this.getEncryptPassword(e.loginPassword).pipe(u.map((function(o){return o.loginID=e.loginId,t.http.request(r,n,{body:o,observe:"response"}).pipe(u.map((function(r){if(t.getOption("login.alwaysFail"))throw t.createFailResponse(e);if(!t.getOption("success.getter")("login",r,t.options))throw new P(t.getOption("messages.getter")("login",r,t.options));return r})),u.map((function(e){return new s.NbAuthResult(!0,e,t.getOption("login.redirect.success"),[],t.getOption("messages.getter")("login",e,t.options))})),u.catchError((function(e){return t.handleResponseError(e,"login")})))})),u.concatAll())},r.prototype.logout=function(){var e=this,t=this.getOption("logout.method"),r=this.getActionEndpoint("logout");return l.of({}).pipe(u.switchMap((function(n){return r?e.http.request(t,r,{observe:"response"}):l.of(n)})),u.map((function(t){if(e.getOption("logout.alwaysFail"))throw e.createFailResponse();return t})),u.map((function(t){return new s.NbAuthResult(!0,t,e.getOption("logout.redirect.success"),[],e.getOption("messages.getter")("logout",t,e.options))})),u.catchError((function(t){return e.handleResponseError(t,"logout")})))},r.prototype.refreshToken=function(e){},r.prototype.register=function(e){},r.prototype.requestPassword=function(e){},r.prototype.resetPassword=function(e){var t=this,r="resetPass",n=this.getOption(r+".method"),o=this.getActionEndpoint(r);return this.getEncryptPassword(e.loginPasswordNew+"-"+e.loginPasswordOld).pipe(u.map((function(a){return a.passwordData=a.loginPassword,t.http.request(n,o,{body:a,observe:"response"}).pipe(u.map((function(n){if(t.getOption(r+".alwaysFail"))throw t.createFailResponse(e);if(!t.getOption("success.getter")(r,n,t.options))throw new P(t.getOption("messages.getter")(r,n,t.options));return n})),u.map((function(e){return new s.NbAuthResult(!0,e,t.getOption(r+".redirect.success"),[],t.getOption("messages.getter")(r,e,t.options))})),u.catchError((function(e){return t.handleResponseError(e,r)})))})),u.concatAll())},r.prototype.createUser=function(e){var t=this,r="createUser",n=this.getOption(r+".method"),o=this.getActionEndpoint(r);return this.getEncryptPassword(e.loginPassword).pipe(u.map((function(a){return a.userName=e.userName,a.loginID=e.loginID,t.http.request(n,o,{body:a,observe:"response"}).pipe(u.map((function(n){if(t.getOption(r+".alwaysFail"))throw t.createFailResponse(e);if(!t.getOption("success.getter")(r,n,t.options))throw new P(t.getOption("messages.getter")(r,n,t.options));return n})),u.map((function(e){return new s.NbAuthResult(!0,e,t.getOption(r+".redirect.success"),[],t.getOption("messages.getter")(r,e,t.options))})),u.catchError((function(e){return t.handleResponseError(e,r)})))})),u.concatAll())},r.prototype.updatePasswordForAdmin=function(e){var t=this,r="updatePasswordForAdmin",n=this.getOption(r+".method"),o=this.getActionEndpoint(r);return this.getEncryptPassword(e.loginPassword).pipe(u.map((function(a){return a.userID=e.userID,t.http.request(n,o,{body:a,observe:"response"}).pipe(u.map((function(n){if(t.getOption(r+".alwaysFail"))throw t.createFailResponse(e);if(!t.getOption("success.getter")(r,n,t.options))throw new P(t.getOption("messages.getter")(r,n,t.options));return n})),u.map((function(e){return new s.NbAuthResult(!0,e,t.getOption(r+".redirect.success"),[],t.getOption("messages.getter")(r,e,t.options))})),u.catchError((function(e){return t.handleResponseError(e,r)})))})),u.concatAll())},r.prototype.getEncryptPassword=function(e){var t=this,r="getPublicKey",n=this.getOption(r+".method"),s=this.getActionEndpoint(r);return this.http.request(n,s,{observe:"response"}).pipe(u.map((function(t){return function(e,t){var r=Date.now(),n=new g.JSEncrypt;n.setPublicKey(e.data.publicPEMKey);var s=n.encrypt(t+r);return{cryptoKeyID:e.data.cryptoKeyID,utcTimestamp:r,loginPassword:s}}(t.body,e)})),u.catchError((function(e){return t.handleResponseError(e,r)})))},r.prototype.handleResponseError=function(e,t){var r=[];return e instanceof c.HttpErrorResponse?r=this.getOption("errors.getter")(t,e,this.options):e instanceof s.NbAuthIllegalTokenError?r.push(e.message):e instanceof P?r=e.message:r.push("Something went wrong."),l.of(new s.NbAuthResult(!1,e,this.getOption(t+".redirect.failure"),r))},r.decorators=[{type:t.Injectable}],r.ctorParameters=function(){return[{type:c.HttpClient},{type:n.ActivatedRoute}]},r}(s.NbAuthStrategy),I=function(){function e(e,t,r,n,s){void 0===r&&(r={}),this.service=e,this.langService=t,this.options=r,this.cd=n,this.router=s,this.redirectDelay=0,this.showMessages={},this.strategy="",this.submitted=!1,this.errors=[],this.messages=[],this.user={},this.redirectDelay=this.getConfigValue("forms.resetPassword.redirectDelay"),this.showMessages=this.getConfigValue("forms.resetPassword.showMessages"),this.strategy=this.getConfigValue("forms.resetPassword.strategy")}return e.prototype.resetPass=function(){var e=this;this.errors=this.messages=[],this.submitted=!0,this.service.resetPassword(this.strategy,this.user).subscribe((function(t){e.submitted=!1,t.isSuccess()?e.messages=t.getMessages():e.errors=t.getErrors();var r=t.getRedirect();r&&setTimeout((function(){return e.router.navigateByUrl(r)}),e.redirectDelay),e.cd.detectChanges()}))},e.prototype.getConfigValue=function(e){return y(this.options,e,null)},e.decorators=[{type:t.Component,args:[{selector:"auth-reset-password-page",template:'

修改密码

\r\n

请设置您的新密码

\r\n\r\n\r\n

错误!

\r\n
    \r\n
  • {{ error }}
  • \r\n
\r\n
\r\n\r\n\r\n

成功!

\r\n
    \r\n
  • {{ message }}
  • \r\n
\r\n
\r\n\r\n
\r\n\r\n
\r\n \r\n \r\n \r\n

\r\n\r\n

\r\n

\r\n 密码应该包含\r\n 最小长度 {{ getConfigValue(\'forms.validation.password.minLength\') }}\r\n 最大长度 {{ getConfigValue(\'forms.validation.password.maxLength\') }}\r\n 个字符\r\n

\r\n
\r\n
\r\n\r\n
\r\n \r\n \r\n \r\n

\r\n\r\n

\r\n

\r\n\r\n 密码应该包含\r\n 最小长度 {{ getConfigValue(\'forms.validation.password.minLength\') }}\r\n 最大长度 {{ getConfigValue(\'forms.validation.password.maxLength\') }}\r\n 个字符\r\n

\r\n
\r\n
\r\n\r\n
\r\n \r\n \r\n \r\n

\r\n\r\n

\r\n

\r\n
\r\n
\r\n\r\n \r\n
\r\n\r\n\x3c!----\x3e\r\n',changeDetection:t.ChangeDetectionStrategy.OnPush,styles:[":host .form-group:last-of-type{margin-bottom:3rem}"]}]}],e.ctorParameters=function(){return[{type:s.NbAuthService},{type:w},{type:void 0,decorators:[{type:t.Inject,args:[s.NB_AUTH_OPTIONS]}]},{type:t.ChangeDetectorRef},{type:n.Router}]},e}(),O=function(){function e(e,t,r,n){void 0===r&&(r={}),this.service=e,this.langService=t,this.options=r,this.router=n,this.redirectDelay=0,this.strategy="",this.redirectDelay=this.getConfigValue("forms.logout.redirectDelay"),this.strategy=this.getConfigValue("forms.logout.strategy")}return e.prototype.ngOnInit=function(){this.logout(this.strategy)},e.prototype.logout=function(e){var t=this;this.service.logout(e).subscribe((function(e){var r=e.getRedirect();r&&setTimeout((function(){return t.router.navigateByUrl(r)}),t.redirectDelay)}))},e.prototype.getConfigValue=function(e){return s.getDeepFromObject(this.options,e,null)},e.decorators=[{type:t.Component,args:[{selector:"auth-logout",template:'
\r\n',styles:["div{text-align:center}"]}]}],e.ctorParameters=function(){return[{type:s.NbAuthService},{type:w},{type:void 0,decorators:[{type:t.Inject,args:[s.NB_AUTH_OPTIONS]}]},{type:n.Router}]},e}(),C=function(){function e(){this.subject=new l.Subject}return e.prototype.changeStatus=function(e){this.status!==e&&(this.status=e,this.subject.next(e))},e.decorators=[{type:t.Injectable}],e.ctorParameters=function(){return[]},e}(),M={Login:1,Logout:2};M[M.Login]="Login",M[M.Logout]="Logout";var k=function(){function e(){}return e.decorators=[{type:t.NgModule,args:[{declarations:[b,I,O],imports:[r.CommonModule,a.NbLayoutModule,a.NbCardModule,a.NbCheckboxModule,a.NbAlertModule,a.NbInputModule,a.NbButtonModule,n.RouterModule,i.FormsModule,o.TranslateModule.forRoot()],providers:[L,C,w],exports:[b,I,O]}]}],e}();e.AUTH_DEFAULT_LANG=m,e.GeAdminAuthModule=k,e.LoginComponent=b,e.LoginLangService=w,e.LoginStatus=M,e.LoginStatusService=C,e.LogoutComponent=O,e.NamePasswordAuthStrategyOptions=v,e.NamePasswordStrategyService=L,e.ResetPasswordComponent=I,e.ResultError=P,e.namePasswordStrategyOptions=x,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=ge-admin-auth.umd.min.js.map