]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+signup/+register/register.component.ts
Improve advanced input filter
[github/Chocobozzz/PeerTube.git] / client / src / app / +signup / +register / register.component.ts
index 8e89bb01a25d66692c9ff28c602f12e61400b7d2..bb727645902a0cf8cab267fe602693e8798b4bee 100644 (file)
@@ -42,6 +42,8 @@ export class RegisterComponent implements OnInit {
   defaultNextStepButtonLabel = $localize`:Button on the registration form to go to the previous step:Next`
   stepUserButtonLabel = this.defaultNextStepButtonLabel
 
+  signupDisabled = false
+
   private serverConfig: ServerConfig
 
   constructor (
@@ -49,16 +51,24 @@ export class RegisterComponent implements OnInit {
     private authService: AuthService,
     private userService: UserService,
     private hooks: HooksService
-    ) {
-  }
+  ) { }
 
   get requiresEmailVerification () {
     return this.serverConfig.signup.requiresEmailVerification
   }
 
+  get minimumAge () {
+    return this.serverConfig.signup.minimumAge
+  }
+
   ngOnInit (): void {
     this.serverConfig = this.route.snapshot.data.serverConfig
 
+    if (this.serverConfig.signup.allowed === false || this.serverConfig.signup.allowedForCurrentIP === false) {
+      this.signupDisabled = true
+      return
+    }
+
     this.videoUploadDisabled = this.serverConfig.user.videoQuota === 0
     this.stepUserButtonLabel = this.videoUploadDisabled
       ? $localize`:Button on the registration form to finalize the account and channel creation:Signup`
@@ -118,8 +128,8 @@ export class RegisterComponent implements OnInit {
       'filter:api.signup.registration.create.params'
     )
 
-    this.userService.signup(body).subscribe(
-      () => {
+    this.userService.signup(body).subscribe({
+      next: () => {
         this.signupDone = true
 
         if (this.requiresEmailVerification) {
@@ -129,16 +139,20 @@ export class RegisterComponent implements OnInit {
 
         // Auto login
         this.authService.login(body.username, body.password)
-            .subscribe(
-              () => {
-                this.success = $localize`You are now logged in as ${body.username}!`
-              },
-
-              err => this.error = err.message
-            )
+          .subscribe({
+            next: () => {
+              this.success = $localize`You are now logged in as ${body.username}!`
+            },
+
+            error: err => {
+              this.error = err.message
+            }
+          })
       },
 
-      err => this.error = err.message
-    )
+      error: err => {
+        this.error = err.message
+      }
+    })
   }
 }