]>
Commit | Line | Data |
---|---|---|
d9eaee39 | 1 | import { Component, OnInit } from '@angular/core' |
67ed6552 | 2 | import { ActivatedRoute } from '@angular/router' |
d92d070c C |
3 | import { AuthService, Notifier } from '@app/core' |
4 | import { UserSignupService } from '@app/shared/shared-users' | |
d9eaee39 JM |
5 | |
6 | @Component({ | |
7 | selector: 'my-verify-account-email', | |
8 | templateUrl: './verify-account-email.component.html' | |
9 | }) | |
10 | ||
11 | export class VerifyAccountEmailComponent implements OnInit { | |
12 | success = false | |
0ba5f5ba C |
13 | failed = false |
14 | isPendingEmail = false | |
d9eaee39 JM |
15 | |
16 | private userId: number | |
17 | private verificationString: string | |
18 | ||
19 | constructor ( | |
d92d070c | 20 | private userSignupService: UserSignupService, |
0ba5f5ba | 21 | private authService: AuthService, |
f8b2c1b4 | 22 | private notifier: Notifier, |
66357162 | 23 | private route: ActivatedRoute |
9df52d66 | 24 | ) { |
d9eaee39 JM |
25 | } |
26 | ||
27 | ngOnInit () { | |
0ba5f5ba C |
28 | const queryParams = this.route.snapshot.queryParams |
29 | this.userId = queryParams['userId'] | |
30 | this.verificationString = queryParams['verificationString'] | |
31 | this.isPendingEmail = queryParams['isPendingEmail'] === 'true' | |
32 | ||
d9eaee39 | 33 | if (!this.userId || !this.verificationString) { |
66357162 | 34 | this.notifier.error($localize`Unable to find user id or verification string.`) |
d9eaee39 JM |
35 | } else { |
36 | this.verifyEmail() | |
37 | } | |
38 | } | |
39 | ||
40 | verifyEmail () { | |
d92d070c | 41 | this.userSignupService.verifyEmail(this.userId, this.verificationString, this.isPendingEmail) |
1378c0d3 C |
42 | .subscribe({ |
43 | next: () => { | |
d1ea2a98 C |
44 | if (this.authService.isLoggedIn()) { |
45 | this.authService.refreshUserInformation() | |
46 | } | |
0ba5f5ba | 47 | |
d9eaee39 | 48 | this.success = true |
d9eaee39 JM |
49 | }, |
50 | ||
1378c0d3 | 51 | error: err => { |
0ba5f5ba C |
52 | this.failed = true |
53 | ||
f8b2c1b4 | 54 | this.notifier.error(err.message) |
d9eaee39 | 55 | } |
1378c0d3 | 56 | }) |
d9eaee39 JM |
57 | } |
58 | } |