UNPKG

@akveo/nga-auth

Version:
64 lines 4.82 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; /** * @license * Copyright Akveo. All Rights Reserved. * Licensed under the MIT License. See License.txt in the project root for license information. */ import { Component } from '@angular/core'; import { Router } from '@angular/router'; import { NgaUser } from '../../models/user'; import { NgaAuthService } from '../../services/auth.service'; var NgaResetPasswordComponent = (function () { function NgaResetPasswordComponent(service, router) { this.service = service; this.router = router; this.redirectDelay = 1500; this.submitted = false; this.errors = []; this.messages = []; this.user = new NgaUser(); } NgaResetPasswordComponent.prototype.resetPass = function (provider) { var _this = this; this.errors = this.messages = []; this.submitted = true; this.service.resetPassword(provider, this.user).subscribe(function (result) { _this.submitted = false; if (result.isSuccess()) { _this.messages = result.getMessages(); } else { _this.errors = result.getErrors(); } var redirect = result.getRedirect(); if (redirect) { setTimeout(function () { return _this.router.navigateByUrl(redirect); }, _this.redirectDelay); } }); }; NgaResetPasswordComponent.prototype.getConfigValue = function (provider, key) { return this.service.getProvider(provider).getConfigValue(key); }; return NgaResetPasswordComponent; }()); NgaResetPasswordComponent = __decorate([ Component({ selector: 'nga-reset-password-page', styles: [""], template: "\n <h2>Change password</h2>\n <form (ngSubmit)=\"resetPass('email')\" #resetPassForm=\"ngForm\">\n\n <div *ngIf=\"errors && errors.length > 0 && !submitted\" class=\"alert alert-danger\" role=\"alert\">\n <div><strong>Oh snap!</strong></div>\n <div *ngFor=\"let error of errors\">{{ error }}</div>\n </div>\n <div *ngIf=\"messages && messages.length > 0 && !submitted\" class=\"alert alert-success\" role=\"alert\">\n <div><strong>Hooray!</strong></div>\n <div *ngFor=\"let message of messages\">{{ message }}</div>\n </div>\n\n <label for=\"input-password\" class=\"sr-only\">New Password</label>\n <input name=\"password\" [(ngModel)]=\"user.password\" type=\"password\" id=\"input-password\"\n class=\"form-control form-control-lg first\" placeholder=\"New Password\" required\n [required]=\"getConfigValue('email', 'validation.password.required')\"\n [minlength]=\"getConfigValue('email', 'validation.password.minLength')\"\n [maxlength]=\"getConfigValue('email', 'validation.password.maxLength')\"\n autofocus>\n\n <label for=\"input-re-password\" class=\"sr-only\">Confirm Password</label>\n <input name=\"confirmPassword\" [(ngModel)]=\"user.confirmPassword\" type=\"password\" id=\"input-re-password\"\n class=\"form-control form-control-lg last\" placeholder=\"Confirm Password\"\n [required]=\"getConfigValue('email', 'validation.password.required')\"\n [minlength]=\"getConfigValue('email', 'validation.password.minLength')\"\n [maxlength]=\"getConfigValue('email', 'validation.password.maxLength')\">\n\n <div class=\"checkbox\"></div>\n\n <button [disabled]=\"submitted || !resetPassForm.form.valid\"\n class=\"btn btn-lg btn-primary btn-block\" type=\"submit\">Change password</button>\n </form>\n\n <div class=\"links\">\n <a routerLink=\"../login\">Login</a> or <a routerLink=\"../register\">Register</a>\n </div>\n ", }), __metadata("design:paramtypes", [NgaAuthService, Router]) ], NgaResetPasswordComponent); export { NgaResetPasswordComponent }; //# sourceMappingURL=reset-password.component.js.map