Skip to content

Commit

Permalink
Step 19.27: Create the recover component
Browse files Browse the repository at this point in the history
  • Loading branch information
dotansimha committed Nov 27, 2016
1 parent 9f93ba9 commit 51aa040
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions client/imports/app/auth/recover.component.ts
@@ -0,0 +1,41 @@
import {Component, OnInit, NgZone} from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Router } from '@angular/router';
import { Accounts } from 'meteor/accounts-base';

import template from './recover.component.html';

@Component({
selector: 'recover',
template
})
export class RecoverComponent implements OnInit {
recoverForm: FormGroup;
error: string;

constructor(private router: Router, private zone: NgZone, private formBuilder: FormBuilder) {}

ngOnInit() {
this.recoverForm = this.formBuilder.group({
email: ['', Validators.required]
});

this.error = '';
}

recover() {
if (this.recoverForm.valid) {
Accounts.forgotPassword({
email: this.recoverForm.value.email
}, (err) => {
if (err) {
this.zone.run(() => {
this.error = err;
});
} else {
this.router.navigate(['/']);
}
});
}
}
}

0 comments on commit 51aa040

Please sign in to comment.