/** * @license * Copyright Akveo. All Rights Reserved. * Licensed under the MIT License. See License.txt in the project root for license information. */ import { Component, Inject } from '@angular/core'; import { Router } from '@angular/router'; import { NB_AUTH_OPTIONS_TOKEN } from '../../auth.options'; import { getDeepFromObject } from '../../helpers'; import { NbAuthResult, NbAuthService } from '../../services/auth.service'; @Component({ selector: 'nb-request-password-page', styleUrls: ['./request-password.component.scss'], template: `

Forgot Password

Enter your email adress and we’ll send a like to reset your password
Email is required! Email should be the real one!
`, }) export class NbRequestPasswordComponent { redirectDelay: number = 0; showMessages: any = {}; provider: string = ''; submitted = false; errors: string[] = []; messages: string[] = []; user: any = {}; constructor(protected service: NbAuthService, @Inject(NB_AUTH_OPTIONS_TOKEN) protected config = {}, protected router: Router) { this.redirectDelay = this.getConfigValue('forms.requestPassword.redirectDelay'); this.showMessages = this.getConfigValue('forms.requestPassword.showMessages'); this.provider = this.getConfigValue('forms.requestPassword.provider'); } requestPass(): void { this.errors = this.messages = []; this.submitted = true; this.service.requestPassword(this.provider, this.user).subscribe((result: NbAuthResult) => { this.submitted = false; if (result.isSuccess()) { this.messages = result.getMessages(); } else { this.errors = result.getErrors(); } const redirect = result.getRedirect(); if (redirect) { setTimeout(() => { return this.router.navigateByUrl(redirect); }, this.redirectDelay); } }); } getConfigValue(key: string): any { return getDeepFromObject(this.config, key, null); } }