]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+signup/+verify-account/verify-account-ask-send-email/verify-account-ask-send-email.component.ts
Allow configuration to be static/readonly (#4315)
[github/Chocobozzz/PeerTube.git] / client / src / app / +signup / +verify-account / verify-account-ask-send-email / verify-account-ask-send-email.component.ts
index 830dd996234f45bc3b16fa2760e41a1a88d0f834..83c24a2513b7bd1eb94e67377ab4b79177ed8f09 100644 (file)
@@ -2,7 +2,6 @@ import { Component, OnInit } from '@angular/core'
 import { Notifier, RedirectService, ServerService, UserService } from '@app/core'
 import { USER_EMAIL_VALIDATOR } from '@app/shared/form-validators/user-validators'
 import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
-import { ServerConfig } from '@shared/models'
 
 @Component({
   selector: 'my-verify-account-ask-send-email',
@@ -11,7 +10,7 @@ import { ServerConfig } from '@shared/models'
 })
 
 export class VerifyAccountAskSendEmailComponent extends FormReactive implements OnInit {
-  private serverConfig: ServerConfig
+  requiresEmailVerification = false
 
   constructor (
     protected formValidatorService: FormValidatorService,
@@ -19,18 +18,13 @@ export class VerifyAccountAskSendEmailComponent extends FormReactive implements
     private serverService: ServerService,
     private notifier: Notifier,
     private redirectService: RedirectService
-    ) {
+  ) {
     super()
   }
 
-  get requiresEmailVerification () {
-    return this.serverConfig.signup.requiresEmailVerification
-  }
-
   ngOnInit () {
-    this.serverConfig = this.serverService.getTmpConfig()
     this.serverService.getConfig()
-        .subscribe(config => this.serverConfig = config)
+        .subscribe(config => this.requiresEmailVerification = config.signup.requiresEmailVerification)
 
     this.buildForm({
       'verify-email-email': USER_EMAIL_VALIDATOR
@@ -40,15 +34,13 @@ export class VerifyAccountAskSendEmailComponent extends FormReactive implements
   askSendVerifyEmail () {
     const email = this.form.value['verify-email-email']
     this.userService.askSendVerifyEmail(email)
-      .subscribe(
-        () => {
+      .subscribe({
+        next: () => {
           this.notifier.success($localize`An email with verification link will be sent to ${email}.`)
           this.redirectService.redirectToHomepage()
         },
 
-        err => {
-          this.notifier.error(err.message)
-        }
-      )
+        error: err => this.notifier.error(err.message)
+      })
   }
 }