@akveo/nga-auth
Version:
@akveo/nga-auth
64 lines • 4.11 kB
JavaScript
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 NgaRequestPasswordComponent = (function () {
function NgaRequestPasswordComponent(service, router) {
this.service = service;
this.router = router;
this.redirectDelay = 1500;
this.submitted = false;
this.errors = [];
this.messages = [];
this.user = new NgaUser();
}
NgaRequestPasswordComponent.prototype.requestPass = function (provider) {
var _this = this;
this.errors = this.messages = [];
this.submitted = true;
this.service.requestPassword(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);
}
});
};
NgaRequestPasswordComponent.prototype.getConfigValue = function (provider, key) {
return this.service.getProvider(provider).getConfigValue(key);
};
return NgaRequestPasswordComponent;
}());
NgaRequestPasswordComponent = __decorate([
Component({
selector: 'nga-request-password-page',
styles: [""],
template: "\n <h2>Request password reset</h2>\n <form (ngSubmit)=\"requestPass('email')\" #requestPassForm=\"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-email\" class=\"sr-only\">Enter your email address</label>\n <input name=\"email\" [(ngModel)]=\"user.email\" type=\"email\" id=\"input-email\"\n class=\"form-control form-control-lg\" placeholder=\"Email address\"\n [required]=\"getConfigValue('email', 'validation.email.required')\"\n autofocus>\n <div class=\"checkbox\"></div>\n\n <button [disabled]=\"submitted || !requestPassForm.form.valid\"\n class=\"btn btn-lg btn-primary btn-block\" type=\"submit\">Request 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])
], NgaRequestPasswordComponent);
export { NgaRequestPasswordComponent };
//# sourceMappingURL=request-password.component.js.map