1 import { Component, OnInit } from '@angular/core'
2 import { ActivatedRoute } from '@angular/router'
3 import { SignupService } from '@app/+signup/shared/signup.service'
4 import { AuthService, Notifier, ServerService } from '@app/core'
7 selector: 'my-verify-account-email',
8 templateUrl: './verify-account-email.component.html'
11 export class VerifyAccountEmailComponent implements OnInit {
14 isPendingEmail = false
16 requiresApproval: boolean
19 private userId: number
20 private registrationId: number
21 private verificationString: string
24 private signupService: SignupService,
25 private server: ServerService,
26 private authService: AuthService,
27 private notifier: Notifier,
28 private route: ActivatedRoute
33 return this.server.getHTMLConfig().instance.name
37 const queryParams = this.route.snapshot.queryParams
39 this.server.getConfig().subscribe(config => {
40 this.requiresApproval = config.signup.requiresApproval
45 this.userId = queryParams['userId']
46 this.registrationId = queryParams['registrationId']
48 this.verificationString = queryParams['verificationString']
50 this.isPendingEmail = queryParams['isPendingEmail'] === 'true'
52 if (!this.verificationString) {
53 this.notifier.error($localize`Unable to find verification string in URL query.`)
57 if (!this.userId && !this.registrationId) {
58 this.notifier.error($localize`Unable to find user id or registration id in URL query.`)
65 isRegistrationRequest () {
66 return !!this.registrationId
69 displaySignupSuccess () {
70 if (!this.success) return false
71 if (!this.isRegistrationRequest() && this.isPendingEmail) return false
77 if (this.isRegistrationRequest()) {
78 return this.verifyRegistrationEmail()
81 return this.verifyUserEmail()
84 private verifyUserEmail () {
87 verificationString: this.verificationString,
88 isPendingEmail: this.isPendingEmail
91 this.signupService.verifyUserEmail(options)
94 if (this.authService.isLoggedIn()) {
95 this.authService.refreshUserInformation()
104 this.notifier.error(err.message)
109 private verifyRegistrationEmail () {
111 registrationId: this.registrationId,
112 verificationString: this.verificationString
115 this.signupService.verifyRegistrationEmail(options)
124 this.notifier.error(err.message)