1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060 |
- (function (global, factory) {
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(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')) :
- typeof define === 'function' && 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'], factory) :
- (global = global || self, factory(global['ge-admin-auth'] = {}, global.ng.core, global.ng.common, global.ng.router, global.auth, global.core$1, global.theme, global.ng.forms, global.rxjs, global.rxjs.operators, global.ng.common.http, global.jsencrypt));
- }(this, (function (exports, core, common, router, auth, core$1, theme, forms, rxjs, operators, http, jsencrypt) { '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.
- ***************************************************************************** */
- /* global Reflect, Promise */
- var extendStatics = function(d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- function __extends(d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- }
- function __values(o) {
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
- if (m) return m.call(o);
- if (o && typeof o.length === "number") return {
- next: function () {
- if (o && i >= o.length) o = void 0;
- return { value: o && o[i++], done: !o };
- }
- };
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
- }
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /** @type {?} */
- var lang = {
- '与第一次输入不符合': '与第一次输入不符合.',
- '修改密码': '修改密码',
- '密码': '密码',
- '密码:': '密码:',
- '密码是必填的': '密码是必填的',
- '密码规则提示': '密码应该包含 最小长度 {{minLength}} 最大长度 {{maxLength}} 个字符',
- '您好,欢迎使用': '您好,欢迎使用',
- '成功!': '成功!',
- '新密码': '新密码',
- '新密码:': '新密码:',
- '新密码是必填的!': '新密码是必填的!',
- '旧密码:': '旧密码:',
- '旧密码是必填的!': '旧密码是必填的',
- '登出提示': '正在登出, 请等待...',
- '登录': '登录',
- '确认密码': '确认密码',
- '确认密码:': '确认密码:',
- '确认密码是必填的!': '确认密码是必填的!',
- '请设置您的新密码': '请设置您的新密码',
- '账户': '账户',
- '账户:': '账户:',
- '账户是必填的': '账户是必填的',
- '错误!': '错误!'
- };
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /** @type {?} */
- var lang$1 = {
- '与第一次输入不符合': '與第一次輸入不符合.',
- '修改密码': '更改密碼',
- '密码': '密碼',
- '密码:': '密碼:',
- '密码是必填的': '必須填寫密碼',
- '密码规则提示': '密碼應該包含 最小長度 {{minLength}} 最大長度 {{maxLength}} 個字符',
- '您好,欢迎使用': '您好,歡迎使用',
- '成功!': '成功!',
- '新密码': '新密碼',
- '新密码:': '新密碼:',
- '新密码是必填的!': '必須填寫新密碼',
- '旧密码:': '舊密碼:',
- '旧密码是必填的!': '必須填寫舊密碼',
- '登出提示': '正在登出, 請稍候⋯',
- '登录': '登入',
- '确认密码': '確認密碼',
- '确认密码:': '確認密碼:',
- '确认密码是必填的!': '必須填寫確認密碼',
- '请设置您的新密码': '請設置您的新密碼',
- '账户': '賬戶',
- '账户:': '賬戶:',
- '账户是必填的': '必須填寫賬戶',
- '错误!': '錯誤!'
- };
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /** @type {?} */
- var AUTH_DEFAULT_LANG = new core.InjectionToken('AUTH_DEFAULT_LANG');
- var LoginLangService = /** @class */ (function () {
- function LoginLangService(_translate, lang$2) {
- this._translate = _translate;
- this._translate.setTranslation('zh-cn', lang);
- this._translate.setTranslation('zh-hk', lang$1);
- this._translate.setDefaultLang(lang$2 ? lang$2 : 'zh-cn');
- this._translate.use(lang$2 ? lang$2 : 'zh-cn');
- }
- /**
- * @param {?=} lang
- * @return {?}
- */
- LoginLangService.prototype.setTranslate = /**
- * @param {?=} lang
- * @return {?}
- */
- function (lang) {
- this._translate.use(lang);
- };
- LoginLangService.decorators = [
- { type: core.Injectable }
- ];
- /** @nocollapse */
- LoginLangService.ctorParameters = function () { return [
- { type: core$1.TranslateService },
- { type: String, decorators: [{ type: core.Optional }, { type: core.Inject, args: [AUTH_DEFAULT_LANG,] }] }
- ]; };
- return LoginLangService;
- }());
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- // getDeepFromObject({result: {data: 1}}, 'result.data', 2); // returns 1
- /**
- * @param {?=} object
- * @param {?=} name
- * @param {?=} defaultValue
- * @return {?}
- */
- function getDeepFromObject(object, name, defaultValue) {
- var e_1, _a;
- if (object === void 0) { object = {}; }
- /** @type {?} */
- var keys = name.split('.');
- // clone the object
- /** @type {?} */
- var currentValue = object;
- try {
- for (var keys_1 = __values(keys), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) {
- var key = keys_1_1.value;
- if (currentValue) {
- currentValue = currentValue[key];
- }
- else {
- break;
- }
- }
- }
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
- finally {
- try {
- if (keys_1_1 && !keys_1_1.done && (_a = keys_1.return)) _a.call(keys_1);
- }
- finally { if (e_1) throw e_1.error; }
- }
- return typeof currentValue === 'undefined' ? defaultValue : currentValue;
- }
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- var LoginComponent = /** @class */ (function () {
- function LoginComponent(service, langService, options, cd, router) {
- if (options === void 0) { options = {}; }
- this.service = service;
- this.langService = langService;
- this.options = options;
- this.cd = cd;
- this.router = router;
- this.redirectDelay = 0;
- this.showMessages = {};
- this.strategy = '';
- this.errors = [];
- this.messages = [];
- this.user = {};
- this.submitted = false;
- this.socialLinks = [];
- this.rememberMe = false;
- 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 {?}
- */
- LoginComponent.prototype.login = /**
- * @return {?}
- */
- function () {
- var _this = this;
- this.errors = [];
- this.messages = [];
- this.submitted = true;
- this.service.authenticate(this.strategy, this.user).subscribe((/**
- * @param {?} result
- * @return {?}
- */
- function (result) {
- _this.submitted = false;
- if (result.isSuccess()) {
- _this.messages = result.getMessages();
- }
- else {
- _this.errors = result.getErrors();
- }
- /** @type {?} */
- var redirect = result.getRedirect();
- if (redirect) {
- setTimeout((/**
- * @return {?}
- */
- function () {
- return _this.router.navigateByUrl(redirect);
- }), _this.redirectDelay);
- }
- _this.cd.detectChanges();
- }));
- };
- /**
- * @param {?} key
- * @return {?}
- */
- LoginComponent.prototype.getConfigValue = /**
- * @param {?} key
- * @return {?}
- */
- function (key) {
- return getDeepFromObject(this.options, key, null);
- };
- LoginComponent.decorators = [
- { type: core.Component, args: [{
- selector: 'auth-login',
- template: "<h1 id=\"title\" class=\"title\" translate>\u767B\u5F55</h1>\r\n<p class=\"sub-title\" translate>\u60A8\u597D,\u6B22\u8FCE\u4F7F\u7528</p>\r\n\r\n<nb-alert *ngIf=\"showMessages.error && errors?.length && !submitted\" outline=\"danger\" role=\"alert\">\r\n <p class=\"alert-title\"><b translate>\u9519\u8BEF!</b></p>\r\n <ul class=\"alert-message-list\">\r\n <li *ngFor=\"let error of errors\" class=\"alert-message\">{{ error }}</li>\r\n </ul>\r\n</nb-alert>\r\n\r\n<nb-alert\r\n *ngIf=\"showMessages.success && messages?.length && !submitted\"\r\n outline=\"success\"\r\n role=\"alert\"\r\n>\r\n <p class=\"alert-title\"><b translate>\u6210\u529F!</b></p>\r\n <ul class=\"alert-message-list\">\r\n <li *ngFor=\"let message of messages\" class=\"alert-message\">{{ message }}</li>\r\n </ul>\r\n</nb-alert>\r\n\r\n<form (ngSubmit)=\"login()\" #form=\"ngForm\" aria-labelledby=\"title\">\r\n <div class=\"form-control-group\">\r\n <label class=\"label\" for=\"input-email\" translate>\u8D26\u6237:</label>\r\n <input\r\n nbInput\r\n fullWidth\r\n [(ngModel)]=\"user.loginId\"\r\n #loginId=\"ngModel\"\r\n name=\"loginId\"\r\n id=\"input-loginId\"\r\n placeholder=\"{{ '\u8D26\u6237' | translate }}\"\r\n autofocus\r\n [status]=\"loginId.dirty ? (loginId.invalid ? 'danger' : 'success') : ''\"\r\n [required]=\"true\"\r\n [attr.aria-invalid]=\"loginId.invalid && loginId.touched ? true : null\"\r\n />\r\n <ng-container *ngIf=\"loginId.invalid && loginId.touched\">\r\n <p class=\"error-message\" *ngIf=\"loginId.errors?.required\" translate=\"\u8D26\u6237\u662F\u5FC5\u586B\u7684\">\r\n\r\n </p>\r\n </ng-container>\r\n </div>\r\n\r\n <div class=\"form-control-group\">\r\n <label class=\"label\" for=\"input-password\" translate>\u5BC6\u7801:</label>\r\n <input\r\n nbInput\r\n fullWidth\r\n [(ngModel)]=\"user.loginPassword\"\r\n #password=\"ngModel\"\r\n name=\"password\"\r\n type=\"password\"\r\n id=\"input-password\"\r\n placeholder=\"{{'\u5BC6\u7801'|translate}}\"\r\n [status]=\"password.dirty ? (password.invalid ? 'danger' : 'success') : ''\"\r\n [required]=\"true\"\r\n [minlength]=\"getConfigValue('forms.validation.password.minLength')\"\r\n [maxlength]=\"getConfigValue('forms.validation.password.maxLength')\"\r\n [attr.aria-invalid]=\"password.invalid && password.touched ? true : null\"\r\n />\r\n <ng-container *ngIf=\"password.invalid && password.touched\">\r\n <p class=\"error-message\" *ngIf=\"password.errors?.required\" translate=\"\u5BC6\u7801\u662F\u5FC5\u586B\u7684\">\r\n\r\n </p>\r\n <p class=\"error-message\" *ngIf=\"password.errors?.minlength || password.errors?.maxlength\"\r\n translate=\"\u5BC6\u7801\u89C4\u5219\u63D0\u793A\" [translateParams]=\"{minLength: getConfigValue('forms.validation.password.minLength'), maxLength:getConfigValue('forms.validation.password.maxLength')}\"\r\n >\r\n \u5BC6\u7801\u5E94\u8BE5\u5305\u542B \u6700\u5C0F\u957F\u5EA6 {{ getConfigValue('forms.validation.password.minLength') }} \u6700\u5927\u957F\u5EA6\r\n {{ getConfigValue('forms.validation.password.maxLength') }}\r\n \u4E2A\u5B57\u7B26\r\n </p>\r\n </ng-container>\r\n </div>\r\n\r\n <!--<div class=\"form-control-group accept-group\">-->\r\n <!--<nb-checkbox name=\"rememberMe\" [(ngModel)]=\"user.rememberMe\" *ngIf=\"rememberMe\">\u8BB0\u4F4F\u8D26\u53F7</nb-checkbox>-->\r\n <!--<!–<a class=\"forgot-password\" routerLink=\"../request-password\">Forgot Password?</a>–>-->\r\n <!--</div>-->\r\n\r\n <button\r\n nbButton\r\n fullWidth\r\n status=\"success\"\r\n [disabled]=\"submitted || !form.valid\"\r\n [class.btn-pulse]=\"submitted\"\r\n translate=\"\u767B\u5F55\"\r\n >\r\n </button>\r\n</form>\r\n\r\n<!--<section *ngIf=\"socialLinks && socialLinks.length > 0\" class=\"links\" aria-label=\"Social sign in\">-->\r\n<!--or enter with:-->\r\n<!--<div class=\"socials\">-->\r\n<!--<ng-container *ngFor=\"let socialLink of socialLinks\">-->\r\n<!--<a *ngIf=\"socialLink.link\"-->\r\n<!--[routerLink]=\"socialLink.link\"-->\r\n<!--[attr.target]=\"socialLink.target\"-->\r\n<!--[attr.class]=\"socialLink.icon\"-->\r\n<!--[class.with-icon]=\"socialLink.icon\">{{ socialLink.title }}</a>-->\r\n<!--<a *ngIf=\"socialLink.url\"-->\r\n<!--[attr.href]=\"socialLink.url\"-->\r\n<!--[attr.target]=\"socialLink.target\"-->\r\n<!--[attr.class]=\"socialLink.icon\"-->\r\n<!--[class.with-icon]=\"socialLink.icon\">{{ socialLink.title }}</a>-->\r\n<!--</ng-container>-->\r\n<!--</div>-->\r\n<!--</section>-->\r\n\r\n<!--<section class=\"another-action\" aria-label=\"Register\">-->\r\n<!--Don't have an account? <a class=\"text-link\" routerLink=\"../register\">Register</a>-->\r\n<!--</section>-->\r\n",
- changeDetection: core.ChangeDetectionStrategy.OnPush
- }] }
- ];
- /** @nocollapse */
- LoginComponent.ctorParameters = function () { return [
- { type: auth.NbAuthService },
- { type: LoginLangService },
- { type: undefined, decorators: [{ type: core.Inject, args: [auth.NB_AUTH_OPTIONS,] }] },
- { type: core.ChangeDetectorRef },
- { type: router.Router }
- ]; };
- return LoginComponent;
- }());
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- var NamePasswordAuthStrategyOptions = /** @class */ (function (_super) {
- __extends(NamePasswordAuthStrategyOptions, _super);
- function NamePasswordAuthStrategyOptions() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- _this.baseEndpoint = '/api/auth/';
- _this.getPublicKey = {
- endpoint: 'getPublicKey',
- method: 'get'
- };
- _this.login = {
- alwaysFail: false,
- endpoint: 'login',
- method: 'post',
- redirect: {
- success: '/',
- failure: null
- },
- defaultErrors: ['未知错误!'],
- defaultMessages: ['You have been successfully logged in.']
- };
- _this.createUser = {
- endpoint: 'createUser',
- method: 'post',
- defaultErrors: ['未知错误!']
- };
- _this.updatePasswordForAdmin = {
- endpoint: 'updatePasswordForAdmin',
- method: 'patch',
- defaultErrors: ['未知错误!']
- };
- _this.register = {
- alwaysFail: false,
- endpoint: 'register',
- method: 'post',
- redirect: {
- success: '/',
- failure: null
- },
- defaultErrors: ['Something went wrong, please try again.'],
- defaultMessages: ['You have been successfully registered.']
- };
- _this.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.']
- };
- _this.resetPass = {
- endpoint: 'updateUserPassword',
- method: 'patch',
- redirect: {
- success: '/',
- failure: null
- },
- defaultErrors: ['未知错误.'],
- defaultMessages: ['Your password has been successfully changed.']
- };
- _this.logout = {
- alwaysFail: false,
- endpoint: 'logout',
- method: 'delete',
- redirect: {
- success: '/',
- failure: null
- },
- defaultErrors: ['Something went wrong, please try again.'],
- defaultMessages: ['You have been successfully logged out.']
- };
- _this.errors = {
- key: 'messager',
- getter: (/**
- * @param {?} module
- * @param {?} res
- * @param {?} options
- * @return {?}
- */
- function (module, res, options) { return [
- getDeepFromObject(res.error, options.errors.key, options[module].defaultErrors)
- ]; })
- };
- _this.messages = {
- key: 'messager',
- getter: (/**
- * @param {?} module
- * @param {?} res
- * @param {?} options
- * @return {?}
- */
- function (module, res, options) { return [getDeepFromObject(res.body, options.messages.key, false)]; })
- };
- _this.success = {
- key: 'success',
- getter: (/**
- * @param {?} module
- * @param {?} res
- * @param {?} options
- * @return {?}
- */
- function (module, res, options) {
- return getDeepFromObject(res.body, options.success.key, options[module].defaultMessages);
- })
- };
- return _this;
- }
- return NamePasswordAuthStrategyOptions;
- }(auth.NbAuthStrategyOptions));
- /** @type {?} */
- var namePasswordStrategyOptions = new NamePasswordAuthStrategyOptions();
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- var ResultError = /** @class */ (function () {
- function ResultError(message) {
- this.message = message;
- }
- return ResultError;
- }());
- var NamePasswordStrategyService = /** @class */ (function (_super) {
- __extends(NamePasswordStrategyService, _super);
- function NamePasswordStrategyService(http, route) {
- var _this = _super.call(this) || this;
- _this.http = http;
- _this.route = route;
- _this.defaultOptions = namePasswordStrategyOptions;
- return _this;
- }
- /**
- * @param {?} options
- * @return {?}
- */
- NamePasswordStrategyService.setup = /**
- * @param {?} options
- * @return {?}
- */
- function (options) {
- return [NamePasswordStrategyService, options];
- };
- /**
- * @param {?=} data
- * @return {?}
- */
- NamePasswordStrategyService.prototype.authenticate = /**
- * @param {?=} data
- * @return {?}
- */
- function (data) {
- var _this = this;
- /** @type {?} */
- var module = 'login';
- /** @type {?} */
- var method = this.getOption(module + ".method");
- /** @type {?} */
- var url = this.getActionEndpoint(module);
- /** @type {?} */
- var requireValidToken = this.getOption(module + ".requireValidToken");
- return this.getEncryptPassword(data.loginPassword).pipe(operators.map((/**
- * @param {?} body
- * @return {?}
- */
- function (body) {
- body.loginID = data.loginId;
- return _this.http.request(method, url, { body: body, observe: 'response' })
- .pipe(operators.map((/**
- * @param {?} res
- * @return {?}
- */
- function (res) {
- if (_this.getOption(module + ".alwaysFail")) {
- throw _this.createFailResponse(data);
- }
- else if (!_this.getOption('success.getter')(module, res, _this.options)) {
- throw new ResultError(_this.getOption('messages.getter')(module, res, _this.options));
- }
- return res;
- })), operators.map((/**
- * @param {?} res
- * @return {?}
- */
- function (res) {
- return new auth.NbAuthResult(true, res, _this.getOption(module + ".redirect.success"), [], _this.getOption('messages.getter')(module, res, _this.options));
- })), operators.catchError((/**
- * @param {?} res
- * @return {?}
- */
- function (res) {
- return _this.handleResponseError(res, module);
- })));
- })), operators.concatAll());
- };
- /**
- * @return {?}
- */
- NamePasswordStrategyService.prototype.logout = /**
- * @return {?}
- */
- function () {
- var _this = this;
- /** @type {?} */
- var module = 'logout';
- /** @type {?} */
- var method = this.getOption(module + ".method");
- /** @type {?} */
- var url = this.getActionEndpoint(module);
- return rxjs.of({})
- .pipe(operators.switchMap((/**
- * @param {?} res
- * @return {?}
- */
- function (res) {
- if (!url) {
- return rxjs.of(res);
- }
- return _this.http.request(method, url, { observe: 'response' });
- })), operators.map((/**
- * @param {?} res
- * @return {?}
- */
- function (res) {
- if (_this.getOption(module + ".alwaysFail")) {
- throw _this.createFailResponse();
- }
- return res;
- })), operators.map((/**
- * @param {?} res
- * @return {?}
- */
- function (res) {
- return new auth.NbAuthResult(true, res, _this.getOption(module + ".redirect.success"), [], _this.getOption('messages.getter')(module, res, _this.options));
- })), operators.catchError((/**
- * @param {?} res
- * @return {?}
- */
- function (res) {
- return _this.handleResponseError(res, module);
- })));
- };
- /**
- * @param {?=} data
- * @return {?}
- */
- NamePasswordStrategyService.prototype.refreshToken = /**
- * @param {?=} data
- * @return {?}
- */
- function (data) {
- return undefined;
- };
- /**
- * @param {?=} data
- * @return {?}
- */
- NamePasswordStrategyService.prototype.register = /**
- * @param {?=} data
- * @return {?}
- */
- function (data) {
- return undefined;
- };
- /**
- * @param {?=} data
- * @return {?}
- */
- NamePasswordStrategyService.prototype.requestPassword = /**
- * @param {?=} data
- * @return {?}
- */
- function (data) {
- return undefined;
- };
- /**
- * @param {?=} data
- * @return {?}
- */
- NamePasswordStrategyService.prototype.resetPassword = /**
- * @param {?=} data
- * @return {?}
- */
- function (data) {
- var _this = this;
- /** @type {?} */
- var module = 'resetPass';
- /** @type {?} */
- var method = this.getOption(module + ".method");
- /** @type {?} */
- var url = this.getActionEndpoint(module);
- return this.getEncryptPassword(data.loginPasswordNew + '-' + data.loginPasswordOld).pipe(operators.map((/**
- * @param {?} body
- * @return {?}
- */
- function (body) {
- body.passwordData = body.loginPassword;
- return _this.http.request(method, url, { body: body, observe: 'response' })
- .pipe(operators.map((/**
- * @param {?} res
- * @return {?}
- */
- function (res) {
- if (_this.getOption(module + ".alwaysFail")) {
- throw _this.createFailResponse(data);
- }
- else if (!_this.getOption('success.getter')(module, res, _this.options)) {
- throw new ResultError(_this.getOption('messages.getter')(module, res, _this.options));
- }
- return res;
- })), operators.map((/**
- * @param {?} res
- * @return {?}
- */
- function (res) {
- return new auth.NbAuthResult(true, res, _this.getOption(module + ".redirect.success"), [], _this.getOption('messages.getter')(module, res, _this.options));
- })), operators.catchError((/**
- * @param {?} res
- * @return {?}
- */
- function (res) {
- return _this.handleResponseError(res, module);
- })));
- })), operators.concatAll());
- };
- /**
- * @param {?=} data
- * @return {?}
- */
- NamePasswordStrategyService.prototype.createUser = /**
- * @param {?=} data
- * @return {?}
- */
- function (data) {
- var _this = this;
- /** @type {?} */
- var module = 'createUser';
- /** @type {?} */
- var method = this.getOption(module + ".method");
- /** @type {?} */
- var url = this.getActionEndpoint(module);
- return this.getEncryptPassword(data.loginPassword).pipe(operators.map((/**
- * @param {?} body
- * @return {?}
- */
- function (body) {
- body.userName = data.userName;
- body.loginID = data.loginID;
- return _this.http.request(method, url, { body: body, observe: 'response' })
- .pipe(operators.map((/**
- * @param {?} res
- * @return {?}
- */
- function (res) {
- if (_this.getOption(module + ".alwaysFail")) {
- throw _this.createFailResponse(data);
- }
- else if (!_this.getOption('success.getter')(module, res, _this.options)) {
- throw new ResultError(_this.getOption('messages.getter')(module, res, _this.options));
- }
- return res;
- })), operators.map((/**
- * @param {?} res
- * @return {?}
- */
- function (res) {
- return new auth.NbAuthResult(true, res, _this.getOption(module + ".redirect.success"), [], _this.getOption('messages.getter')(module, res, _this.options));
- })), operators.catchError((/**
- * @param {?} res
- * @return {?}
- */
- function (res) {
- return _this.handleResponseError(res, module);
- })));
- })), operators.concatAll());
- };
- /**
- * @param {?=} data
- * @return {?}
- */
- NamePasswordStrategyService.prototype.updatePasswordForAdmin = /**
- * @param {?=} data
- * @return {?}
- */
- function (data) {
- var _this = this;
- /** @type {?} */
- var module = 'updatePasswordForAdmin';
- /** @type {?} */
- var method = this.getOption(module + ".method");
- /** @type {?} */
- var url = this.getActionEndpoint(module);
- return this.getEncryptPassword(data.loginPassword).pipe(operators.map((/**
- * @param {?} body
- * @return {?}
- */
- function (body) {
- body.userID = data.userID;
- return _this.http.request(method, url, { body: body, observe: 'response' })
- .pipe(operators.map((/**
- * @param {?} res
- * @return {?}
- */
- function (res) {
- if (_this.getOption(module + ".alwaysFail")) {
- throw _this.createFailResponse(data);
- }
- else if (!_this.getOption('success.getter')(module, res, _this.options)) {
- throw new ResultError(_this.getOption('messages.getter')(module, res, _this.options));
- }
- return res;
- })), operators.map((/**
- * @param {?} res
- * @return {?}
- */
- function (res) {
- return new auth.NbAuthResult(true, res, _this.getOption(module + ".redirect.success"), [], _this.getOption('messages.getter')(module, res, _this.options));
- })), operators.catchError((/**
- * @param {?} res
- * @return {?}
- */
- function (res) {
- return _this.handleResponseError(res, module);
- })));
- })), operators.concatAll());
- };
- /**
- * @param {?} password
- * @return {?}
- */
- NamePasswordStrategyService.prototype.getEncryptPassword = /**
- * @param {?} password
- * @return {?}
- */
- function (password) {
- var _this = this;
- /** @type {?} */
- var module = 'getPublicKey';
- /** @type {?} */
- var method = this.getOption(module + ".method");
- /** @type {?} */
- var url = this.getActionEndpoint(module);
- return this.http.request(method, url, { observe: 'response' })
- .pipe(operators.map((/**
- * @param {?} res
- * @return {?}
- */
- function (res) {
- return encryptPassword(res.body, password);
- })), operators.catchError((/**
- * @param {?} res
- * @return {?}
- */
- function (res) {
- return _this.handleResponseError(res, module);
- })));
- /**
- * @param {?} result
- * @param {?} data
- * @return {?}
- */
- function encryptPassword(result, data) {
- /** @type {?} */
- var now = Date.now();
- /** @type {?} */
- var encrypt = new jsencrypt.JSEncrypt();
- encrypt.setPublicKey(result.data.publicPEMKey);
- /** @type {?} */
- var encryptPass = encrypt.encrypt(data + now);
- return {
- cryptoKeyID: result.data.cryptoKeyID,
- utcTimestamp: now,
- loginPassword: encryptPass
- };
- }
- };
- /**
- * @protected
- * @param {?} res
- * @param {?} module
- * @return {?}
- */
- NamePasswordStrategyService.prototype.handleResponseError = /**
- * @protected
- * @param {?} res
- * @param {?} module
- * @return {?}
- */
- function (res, module) {
- /** @type {?} */
- var errors = [];
- if (res instanceof http.HttpErrorResponse) {
- errors = this.getOption('errors.getter')(module, res, this.options);
- }
- else if (res instanceof auth.NbAuthIllegalTokenError) {
- errors.push(res.message);
- }
- else if (res instanceof ResultError) {
- errors = res.message;
- }
- else {
- errors.push('Something went wrong.');
- }
- return rxjs.of(new auth.NbAuthResult(false, res, this.getOption(module + ".redirect.failure"), errors));
- };
- NamePasswordStrategyService.decorators = [
- { type: core.Injectable }
- ];
- /** @nocollapse */
- NamePasswordStrategyService.ctorParameters = function () { return [
- { type: http.HttpClient },
- { type: router.ActivatedRoute }
- ]; };
- return NamePasswordStrategyService;
- }(auth.NbAuthStrategy));
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- var ResetPasswordComponent = /** @class */ (function () {
- function ResetPasswordComponent(service, langService, options, cd, router) {
- if (options === void 0) { options = {}; }
- this.service = service;
- this.langService = langService;
- this.options = options;
- this.cd = cd;
- this.router = router;
- this.redirectDelay = 0;
- this.showMessages = {};
- this.strategy = '';
- this.submitted = false;
- 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 {?}
- */
- ResetPasswordComponent.prototype.resetPass = /**
- * @return {?}
- */
- function () {
- var _this = this;
- this.errors = this.messages = [];
- this.submitted = true;
- this.service.resetPassword(this.strategy, this.user).subscribe((/**
- * @param {?} result
- * @return {?}
- */
- function (result) {
- _this.submitted = false;
- if (result.isSuccess()) {
- _this.messages = result.getMessages();
- }
- else {
- _this.errors = result.getErrors();
- }
- /** @type {?} */
- var redirect = result.getRedirect();
- if (redirect) {
- setTimeout((/**
- * @return {?}
- */
- function () {
- return _this.router.navigateByUrl(redirect);
- }), _this.redirectDelay);
- }
- _this.cd.detectChanges();
- }));
- };
- /**
- * @param {?} key
- * @return {?}
- */
- ResetPasswordComponent.prototype.getConfigValue = /**
- * @param {?} key
- * @return {?}
- */
- function (key) {
- return getDeepFromObject(this.options, key, null);
- };
- ResetPasswordComponent.decorators = [
- { type: core.Component, args: [{
- selector: 'auth-reset-password-page',
- template: "<h1 id=\"title\" class=\"title\" translate>\u4FEE\u6539\u5BC6\u7801</h1>\r\n<p class=\"sub-title\" translate>\u8BF7\u8BBE\u7F6E\u60A8\u7684\u65B0\u5BC6\u7801</p>\r\n\r\n<nb-alert *ngIf=\"showMessages.error && errors?.length && !submitted\" outline=\"danger\" role=\"alert\">\r\n <p class=\"alert-title\"><b translate>\u9519\u8BEF!</b></p>\r\n <ul class=\"alert-message-list\">\r\n <li *ngFor=\"let error of errors\" class=\"alert-message\">{{ error }}</li>\r\n </ul>\r\n</nb-alert>\r\n\r\n<nb-alert *ngIf=\"showMessages.success && messages?.length && !submitted\" outline=\"success\" role=\"alert\">\r\n <p class=\"alert-title\"><b translate>\u6210\u529F!</b></p>\r\n <ul class=\"alert-message-list\">\r\n <li *ngFor=\"let message of messages\" class=\"alert-message\">{{ message }}</li>\r\n </ul>\r\n</nb-alert>\r\n\r\n<form (ngSubmit)=\"resetPass()\" #resetPassForm=\"ngForm\" aria-labelledby=\"title\">\r\n\r\n <div class=\"form-control-group\">\r\n <label class=\"label\" for=\"input-old-password\" translate>\u65E7\u5BC6\u7801:</label>\r\n <input nbInput\r\n [(ngModel)]=\"user.loginPasswordOld\"\r\n #oldPassword=\"ngModel\"\r\n type=\"password\"\r\n id=\"input-old-password\"\r\n name=\"oldPassword\"\r\n class=\"first\"\r\n placeholder=\"{{'\u65B0\u5BC6\u7801'| translate}}\"\r\n autofocus\r\n fullWidth\r\n [status]=\"oldPassword.dirty ? (oldPassword.invalid ? 'danger' : 'success') : ''\"\r\n [required]=\"getConfigValue('forms.validation.password.required')\"\r\n [minlength]=\"getConfigValue('forms.validation.password.minLength')\"\r\n [maxlength]=\"getConfigValue('forms.validation.password.maxLength')\"\r\n [attr.aria-invalid]=\"oldPassword.invalid && oldPassword.touched ? true : null\">\r\n <ng-container *ngIf=\"oldPassword.invalid && oldPassword.touched\">\r\n <p class=\"error-message\" *ngIf=\"oldPassword.errors?.required\" translate=\"\u65E7\u5BC6\u7801\u662F\u5FC5\u586B\u7684!\">\r\n\r\n </p>\r\n <p class=\"error-message\" *ngIf=\"oldPassword.errors?.minlength || oldPassword.errors?.maxlength\"\r\n translate=\"\u5BC6\u7801\u89C4\u5219\u63D0\u793A\" [translateParams]=\"{minLength: getConfigValue('forms.validation.password.minLength'), maxLength:getConfigValue('forms.validation.password.maxLength')}\">\r\n \u5BC6\u7801\u5E94\u8BE5\u5305\u542B\r\n \u6700\u5C0F\u957F\u5EA6 {{ getConfigValue('forms.validation.password.minLength') }}\r\n \u6700\u5927\u957F\u5EA6 {{ getConfigValue('forms.validation.password.maxLength') }}\r\n \u4E2A\u5B57\u7B26\r\n </p>\r\n </ng-container>\r\n </div>\r\n\r\n <div class=\"form-control-group\">\r\n <label class=\"label\" for=\"input-new-password\" translate>\u65B0\u5BC6\u7801:</label>\r\n <input nbInput\r\n [(ngModel)]=\"user.loginPasswordNew\"\r\n #newPassword=\"ngModel\"\r\n type=\"password\"\r\n id=\"input-new-password\"\r\n name=\"newPassword\"\r\n class=\"first\"\r\n placeholder=\"{{'\u65B0\u5BC6\u7801'| translate}}\"\r\n autofocus\r\n fullWidth\r\n [status]=\"newPassword.dirty ? (newPassword.invalid ? 'danger' : 'success') : ''\"\r\n [required]=\"getConfigValue('forms.validation.password.required')\"\r\n [minlength]=\"getConfigValue('forms.validation.password.minLength')\"\r\n [maxlength]=\"getConfigValue('forms.validation.password.maxLength')\"\r\n [attr.aria-invalid]=\"newPassword.invalid && newPassword.touched ? true : null\">\r\n <ng-container *ngIf=\"newPassword.invalid && newPassword.touched\">\r\n <p class=\"error-message\" *ngIf=\"newPassword.errors?.required\" translate=\"\u65B0\u5BC6\u7801\u662F\u5FC5\u586B\u7684!\">\r\n\r\n </p>\r\n <p class=\"error-message\" *ngIf=\"newPassword.errors?.minlength || newPassword.errors?.maxlength\"\r\n translate=\"\u5BC6\u7801\u89C4\u5219\u63D0\u793A\"\r\n [translateParams]=\"{minLength: getConfigValue('forms.validation.password.minLength'), maxLength:getConfigValue('forms.validation.password.maxLength')}\">\r\n\r\n \u5BC6\u7801\u5E94\u8BE5\u5305\u542B\r\n \u6700\u5C0F\u957F\u5EA6 {{ getConfigValue('forms.validation.password.minLength') }}\r\n \u6700\u5927\u957F\u5EA6 {{ getConfigValue('forms.validation.password.maxLength') }}\r\n \u4E2A\u5B57\u7B26\r\n </p>\r\n </ng-container>\r\n </div>\r\n\r\n <div class=\"form-group\">\r\n <label class=\"label\" for=\"input-re-password\" translate>\u786E\u8BA4\u5BC6\u7801:</label>\r\n <input nbInput\r\n [(ngModel)]=\"user.confirmPassword\"\r\n #rePass=\"ngModel\"\r\n id=\"input-re-password\"\r\n name=\"rePass\"\r\n type=\"password\"\r\n class=\"last\"\r\n placeholder=\"{{'\u786E\u8BA4\u5BC6\u7801'| translate}}\"\r\n fullWidth\r\n [status]=\"rePass.touched\r\n ? (rePass.invalid || newPassword.value != rePass.value ? 'danger' : 'success')\r\n : ''\"\r\n [required]=\"getConfigValue('forms.validation.password.required')\"\r\n [attr.aria-invalid]=\"rePass.invalid && rePass.touched ? true : null\">\r\n <ng-container *ngIf=\"rePass.touched\">\r\n <p class=\"error-message\" *ngIf=\"rePass.invalid && rePass.errors?.required\" translate=\"\u786E\u8BA4\u5BC6\u7801\u662F\u5FC5\u586B\u7684!\">\r\n\r\n </p>\r\n <p class=\"error-message\" *ngIf=\"newPassword.value != rePass.value && !rePass.errors?.required\" translate=\"\u4E0E\u7B2C\u4E00\u6B21\u8F93\u5165\u4E0D\u7B26\u5408\"></p>\r\n </ng-container>\r\n </div>\r\n\r\n <button nbButton\r\n status=\"success\"\r\n fullWidth\r\n [disabled]=\"submitted || !resetPassForm.valid\"\r\n [class.btn-pulse]=\"submitted\" translate=\"\u4FEE\u6539\u5BC6\u7801\">\r\n </button>\r\n</form>\r\n\r\n<!--<section class=\"sign-in-or-up\" aria-label=\"Sign in or sign up\">-->\r\n <!--<p><a class=\"text-link\" routerLink=\"../login\">Back to Log In</a></p>-->\r\n <!--<p><a class=\"text-link\" routerLink=\"../register\">Register</a></p>-->\r\n<!--</section>-->\r\n",
- changeDetection: core.ChangeDetectionStrategy.OnPush,
- styles: [":host .form-group:last-of-type{margin-bottom:3rem}"]
- }] }
- ];
- /** @nocollapse */
- ResetPasswordComponent.ctorParameters = function () { return [
- { type: auth.NbAuthService },
- { type: LoginLangService },
- { type: undefined, decorators: [{ type: core.Inject, args: [auth.NB_AUTH_OPTIONS,] }] },
- { type: core.ChangeDetectorRef },
- { type: router.Router }
- ]; };
- return ResetPasswordComponent;
- }());
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- var LogoutComponent = /** @class */ (function () {
- function LogoutComponent(service, langService, options, router) {
- if (options === void 0) { options = {}; }
- this.service = service;
- this.langService = langService;
- this.options = options;
- this.router = router;
- this.redirectDelay = 0;
- this.strategy = '';
- this.redirectDelay = this.getConfigValue('forms.logout.redirectDelay');
- this.strategy = this.getConfigValue('forms.logout.strategy');
- }
- /**
- * @return {?}
- */
- LogoutComponent.prototype.ngOnInit = /**
- * @return {?}
- */
- function () {
- this.logout(this.strategy);
- };
- /**
- * @param {?} strategy
- * @return {?}
- */
- LogoutComponent.prototype.logout = /**
- * @param {?} strategy
- * @return {?}
- */
- function (strategy) {
- var _this = this;
- this.service.logout(strategy).subscribe((/**
- * @param {?} result
- * @return {?}
- */
- function (result) {
- /** @type {?} */
- var redirect = result.getRedirect();
- if (redirect) {
- setTimeout((/**
- * @return {?}
- */
- function () {
- return _this.router.navigateByUrl(redirect);
- }), _this.redirectDelay);
- }
- }));
- };
- /**
- * @param {?} key
- * @return {?}
- */
- LogoutComponent.prototype.getConfigValue = /**
- * @param {?} key
- * @return {?}
- */
- function (key) {
- return auth.getDeepFromObject(this.options, key, null);
- };
- LogoutComponent.decorators = [
- { type: core.Component, args: [{
- selector: 'auth-logout',
- template: "<div translate=\"\u767B\u51FA\u63D0\u793A\"></div>\r\n",
- styles: ["div{text-align:center}"]
- }] }
- ];
- /** @nocollapse */
- LogoutComponent.ctorParameters = function () { return [
- { type: auth.NbAuthService },
- { type: LoginLangService },
- { type: undefined, decorators: [{ type: core.Inject, args: [auth.NB_AUTH_OPTIONS,] }] },
- { type: router.Router }
- ]; };
- return LogoutComponent;
- }());
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- var LoginStatusService = /** @class */ (function () {
- function LoginStatusService() {
- this.subject = new rxjs.Subject();
- }
- /**
- * @param {?} status
- * @return {?}
- */
- LoginStatusService.prototype.changeStatus = /**
- * @param {?} status
- * @return {?}
- */
- function (status) {
- if (this.status !== status) {
- this.status = status;
- this.subject.next(status);
- }
- };
- LoginStatusService.decorators = [
- { type: core.Injectable }
- ];
- /** @nocollapse */
- LoginStatusService.ctorParameters = function () { return []; };
- return LoginStatusService;
- }());
- /** @enum {number} */
- var LoginStatus = {
- Login: 1,
- Logout: 2,
- };
- LoginStatus[LoginStatus.Login] = 'Login';
- LoginStatus[LoginStatus.Logout] = 'Logout';
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- var GeAdminAuthModule = /** @class */ (function () {
- function GeAdminAuthModule() {
- }
- GeAdminAuthModule.decorators = [
- { type: core.NgModule, args: [{
- declarations: [
- LoginComponent,
- ResetPasswordComponent,
- LogoutComponent
- ],
- imports: [
- common.CommonModule,
- theme.NbLayoutModule,
- theme.NbCardModule,
- theme.NbCheckboxModule,
- theme.NbAlertModule,
- theme.NbInputModule,
- theme.NbButtonModule,
- router.RouterModule,
- forms.FormsModule,
- core$1.TranslateModule.forRoot()
- ],
- providers: [
- NamePasswordStrategyService,
- LoginStatusService,
- LoginLangService
- ],
- exports: [
- LoginComponent,
- ResetPasswordComponent,
- LogoutComponent
- ]
- },] }
- ];
- return GeAdminAuthModule;
- }());
- exports.AUTH_DEFAULT_LANG = AUTH_DEFAULT_LANG;
- exports.GeAdminAuthModule = GeAdminAuthModule;
- exports.LoginComponent = LoginComponent;
- exports.LoginLangService = LoginLangService;
- exports.LoginStatus = LoginStatus;
- exports.LoginStatusService = LoginStatusService;
- exports.LogoutComponent = LogoutComponent;
- exports.NamePasswordAuthStrategyOptions = NamePasswordAuthStrategyOptions;
- exports.NamePasswordStrategyService = NamePasswordStrategyService;
- exports.ResetPasswordComponent = ResetPasswordComponent;
- exports.ResultError = ResultError;
- exports.namePasswordStrategyOptions = namePasswordStrategyOptions;
- Object.defineProperty(exports, '__esModule', { value: true });
- })));
- //# sourceMappingURL=ge-admin-auth.umd.js.map
|