]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+signup/+verify-account/verify-account-email/verify-account-email.component.ts
Merge branch 'release/4.2.0' into develop
[github/Chocobozzz/PeerTube.git] / client / src / app / +signup / +verify-account / verify-account-email / verify-account-email.component.ts
CommitLineData
d9eaee39 1import { Component, OnInit } from '@angular/core'
67ed6552 2import { ActivatedRoute } from '@angular/router'
d92d070c
C
3import { AuthService, Notifier } from '@app/core'
4import { 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
11export 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}