]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - client/src/app/+signup/+verify-account/verify-account-email/verify-account-email.component.ts
Migrate to $localize
[github/Chocobozzz/PeerTube.git] / client / src / app / +signup / +verify-account / verify-account-email / verify-account-email.component.ts
... / ...
CommitLineData
1import { Component, OnInit } from '@angular/core'
2import { ActivatedRoute } from '@angular/router'
3import { AuthService, Notifier, UserService } from '@app/core'
4
5@Component({
6 selector: 'my-verify-account-email',
7 templateUrl: './verify-account-email.component.html'
8})
9
10export class VerifyAccountEmailComponent implements OnInit {
11 success = false
12 failed = false
13 isPendingEmail = false
14
15 private userId: number
16 private verificationString: string
17
18 constructor (
19 private userService: UserService,
20 private authService: AuthService,
21 private notifier: Notifier,
22 private route: ActivatedRoute
23 ) {
24 }
25
26 ngOnInit () {
27 const queryParams = this.route.snapshot.queryParams
28 this.userId = queryParams['userId']
29 this.verificationString = queryParams['verificationString']
30 this.isPendingEmail = queryParams['isPendingEmail'] === 'true'
31
32 if (!this.userId || !this.verificationString) {
33 this.notifier.error($localize`Unable to find user id or verification string.`)
34 } else {
35 this.verifyEmail()
36 }
37 }
38
39 verifyEmail () {
40 this.userService.verifyEmail(this.userId, this.verificationString, this.isPendingEmail)
41 .subscribe(
42 () => {
43 if (this.authService.isLoggedIn()) {
44 this.authService.refreshUserInformation()
45 }
46
47 this.success = true
48 },
49
50 err => {
51 this.failed = true
52
53 this.notifier.error(err.message)
54 }
55 )
56 }
57}