2018-05-31 12:11:31 +00:00
|
|
|
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
2018-05-31 10:20:14 +00:00
|
|
|
import { Store, select } from '@ngrx/store';
|
|
|
|
import { Observable, of } from 'rxjs';
|
|
|
|
import { catchError, exhaustMap, map, tap } from 'rxjs/operators';
|
2018-05-31 12:11:31 +00:00
|
|
|
import { FormBuilder } from '@angular/forms';
|
|
|
|
import { EmailAuthService } from '../service/email-auth.service';
|
|
|
|
import { EmailAuth } from '@overflow/commons-typescript/model/email/EmailAuth';
|
2018-05-30 12:04:53 +00:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'of-member-confirm-reset-password',
|
|
|
|
templateUrl: './member-confirm-reset-password.component.html',
|
|
|
|
})
|
|
|
|
export class MemberConfirmResetPasswordComponent implements OnInit {
|
2018-05-31 10:20:14 +00:00
|
|
|
emailAuth$: Observable<EmailAuth>;
|
|
|
|
pending$: Observable<boolean>;
|
|
|
|
error$: Observable<any>;
|
|
|
|
|
|
|
|
@Input() token: string;
|
|
|
|
@Output() signin = new EventEmitter();
|
|
|
|
@Output() modifyPassword = new EventEmitter();
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
private store: Store<any>,
|
|
|
|
private formBuilder: FormBuilder,
|
|
|
|
private emailAuthService: EmailAuthService,
|
|
|
|
) { }
|
2018-05-30 12:04:53 +00:00
|
|
|
ngOnInit(): void {
|
2018-05-31 10:20:14 +00:00
|
|
|
this.emailAuthService.readByPwAuthKey(this.token)
|
|
|
|
.pipe(
|
|
|
|
tap(() => {
|
|
|
|
this.pending$ = of(true);
|
|
|
|
}),
|
|
|
|
map((emailAuth: EmailAuth) => {
|
|
|
|
this.emailAuth$ = of(emailAuth);
|
|
|
|
}),
|
2018-05-31 12:11:31 +00:00
|
|
|
catchError(err => {
|
2018-05-31 10:20:14 +00:00
|
|
|
this.error$ = of(err);
|
|
|
|
return of();
|
|
|
|
}),
|
|
|
|
tap(() => {
|
|
|
|
this.pending$ = of(false);
|
|
|
|
}),
|
2018-05-31 12:11:31 +00:00
|
|
|
).take(1).subscribe();
|
2018-05-31 10:20:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onModifyPassword() {
|
|
|
|
this.modifyPassword.emit();
|
2018-05-30 12:04:53 +00:00
|
|
|
}
|
|
|
|
}
|