2018-07-13 22:24:53 +02:00
|
|
|
import {
|
|
|
|
Component,
|
|
|
|
OnInit,
|
|
|
|
} from '@angular/core';
|
|
|
|
import {
|
|
|
|
ActivatedRoute,
|
|
|
|
Router,
|
|
|
|
} from '@angular/router';
|
|
|
|
|
2021-10-15 00:59:43 +02:00
|
|
|
import { first } from 'rxjs/operators';
|
|
|
|
|
2018-07-13 22:24:53 +02:00
|
|
|
import { ToasterService } from 'angular2-toaster';
|
|
|
|
|
2021-06-07 20:13:58 +02:00
|
|
|
import { ApiService } from 'jslib-common/abstractions/api.service';
|
|
|
|
import { I18nService } from 'jslib-common/abstractions/i18n.service';
|
2018-07-13 22:24:53 +02:00
|
|
|
|
2021-06-07 20:13:58 +02:00
|
|
|
import { VerifyDeleteRecoverRequest } from 'jslib-common/models/request/verifyDeleteRecoverRequest';
|
2018-07-13 22:24:53 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-verify-recover-delete',
|
|
|
|
templateUrl: 'verify-recover-delete.component.html',
|
|
|
|
})
|
|
|
|
export class VerifyRecoverDeleteComponent implements OnInit {
|
|
|
|
email: string;
|
|
|
|
formPromise: Promise<any>;
|
|
|
|
|
|
|
|
private userId: string;
|
|
|
|
private token: string;
|
|
|
|
|
|
|
|
constructor(private router: Router, private apiService: ApiService,
|
2021-04-14 23:43:40 +02:00
|
|
|
private toasterService: ToasterService, private i18nService: I18nService,
|
|
|
|
private route: ActivatedRoute) {
|
2018-07-13 22:24:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
2021-10-15 00:59:43 +02:00
|
|
|
this.route.queryParams.pipe(first()).subscribe(async qParams => {
|
2018-07-13 22:24:53 +02:00
|
|
|
if (qParams.userId != null && qParams.token != null && qParams.email != null) {
|
|
|
|
this.userId = qParams.userId;
|
|
|
|
this.token = qParams.token;
|
|
|
|
this.email = qParams.email;
|
|
|
|
} else {
|
|
|
|
this.router.navigate(['/']);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async submit() {
|
|
|
|
try {
|
|
|
|
const request = new VerifyDeleteRecoverRequest(this.userId, this.token);
|
|
|
|
this.formPromise = this.apiService.postAccountRecoverDeleteToken(request);
|
|
|
|
await this.formPromise;
|
|
|
|
this.toasterService.popAsync('success', this.i18nService.t('accountDeleted'),
|
|
|
|
this.i18nService.t('accountDeletedDesc'));
|
|
|
|
this.router.navigate(['/']);
|
|
|
|
} catch { }
|
|
|
|
}
|
|
|
|
}
|