diff options
Diffstat (limited to 'client/src/app/signup')
-rw-r--r-- | client/src/app/signup/signup.component.html | 7 | ||||
-rw-r--r-- | client/src/app/signup/signup.component.ts | 34 |
2 files changed, 25 insertions, 16 deletions
diff --git a/client/src/app/signup/signup.component.html b/client/src/app/signup/signup.component.html index aad4b5be3..07d24b381 100644 --- a/client/src/app/signup/signup.component.html +++ b/client/src/app/signup/signup.component.html | |||
@@ -4,6 +4,7 @@ | |||
4 | Create an account | 4 | Create an account |
5 | </div> | 5 | </div> |
6 | 6 | ||
7 | <div *ngIf="info" class="alert alert-info">{{ info }}</div> | ||
7 | <div *ngIf="error" class="alert alert-danger">{{ error }}</div> | 8 | <div *ngIf="error" class="alert alert-danger">{{ error }}</div> |
8 | 9 | ||
9 | <div class="d-flex justify-content-left flex-wrap"> | 10 | <div class="d-flex justify-content-left flex-wrap"> |
@@ -51,7 +52,7 @@ | |||
51 | <div class="form-group form-group-terms"> | 52 | <div class="form-group form-group-terms"> |
52 | <my-peertube-checkbox | 53 | <my-peertube-checkbox |
53 | inputName="terms" formControlName="terms" | 54 | inputName="terms" formControlName="terms" |
54 | i18n-labelHtml labelHtml="I have read and agree to the <a href='/about/instance#terms-section' target='_blank'rel='noopener noreferrer'>Terms</a> of this instance" | 55 | i18n-labelHtml labelHtml="I am at least 16 years old and agree to the <a href='/about/instance#terms-section' target='_blank'rel='noopener noreferrer'>Terms</a> of this instance" |
55 | ></my-peertube-checkbox> | 56 | ></my-peertube-checkbox> |
56 | 57 | ||
57 | <div *ngIf="formErrors.terms" class="form-error"> | 58 | <div *ngIf="formErrors.terms" class="form-error"> |
@@ -59,11 +60,11 @@ | |||
59 | </div> | 60 | </div> |
60 | </div> | 61 | </div> |
61 | 62 | ||
62 | <input type="submit" i18n-value value="Signup" [disabled]="!form.valid"> | 63 | <input type="submit" i18n-value value="Signup" [disabled]="!form.valid || signupDone"> |
63 | </form> | 64 | </form> |
64 | 65 | ||
65 | <div> | 66 | <div> |
66 | <label for="email" i18n>Features found on this instance</label> | 67 | <label i18n>Features found on this instance</label> |
67 | <my-instance-features-table></my-instance-features-table> | 68 | <my-instance-features-table></my-instance-features-table> |
68 | </div> | 69 | </div> |
69 | </div> | 70 | </div> |
diff --git a/client/src/app/signup/signup.component.ts b/client/src/app/signup/signup.component.ts index cf2657b85..13941ec79 100644 --- a/client/src/app/signup/signup.component.ts +++ b/client/src/app/signup/signup.component.ts | |||
@@ -1,8 +1,7 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | 1 | import { Component, OnInit } from '@angular/core' |
2 | import { NotificationsService } from 'angular2-notifications' | 2 | import { AuthService, Notifier, RedirectService, ServerService } from '@app/core' |
3 | import { UserCreate } from '../../../../shared' | 3 | import { UserCreate } from '../../../../shared' |
4 | import { FormReactive, UserService, UserValidatorsService } from '../shared' | 4 | import { FormReactive, UserService, UserValidatorsService } from '../shared' |
5 | import { RedirectService, ServerService } from '@app/core' | ||
6 | import { I18n } from '@ngx-translate/i18n-polyfill' | 5 | import { I18n } from '@ngx-translate/i18n-polyfill' |
7 | import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' | 6 | import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' |
8 | 7 | ||
@@ -12,12 +11,15 @@ import { FormValidatorService } from '@app/shared/forms/form-validators/form-val | |||
12 | styleUrls: [ './signup.component.scss' ] | 11 | styleUrls: [ './signup.component.scss' ] |
13 | }) | 12 | }) |
14 | export class SignupComponent extends FormReactive implements OnInit { | 13 | export class SignupComponent extends FormReactive implements OnInit { |
14 | info: string = null | ||
15 | error: string = null | 15 | error: string = null |
16 | signupDone = false | ||
16 | 17 | ||
17 | constructor ( | 18 | constructor ( |
18 | protected formValidatorService: FormValidatorService, | 19 | protected formValidatorService: FormValidatorService, |
20 | private authService: AuthService, | ||
19 | private userValidatorsService: UserValidatorsService, | 21 | private userValidatorsService: UserValidatorsService, |
20 | private notificationsService: NotificationsService, | 22 | private notifier: Notifier, |
21 | private userService: UserService, | 23 | private userService: UserService, |
22 | private serverService: ServerService, | 24 | private serverService: ServerService, |
23 | private redirectService: RedirectService, | 25 | private redirectService: RedirectService, |
@@ -50,18 +52,24 @@ export class SignupComponent extends FormReactive implements OnInit { | |||
50 | 52 | ||
51 | this.userService.signup(userCreate).subscribe( | 53 | this.userService.signup(userCreate).subscribe( |
52 | () => { | 54 | () => { |
55 | this.signupDone = true | ||
56 | |||
53 | if (this.requiresEmailVerification) { | 57 | if (this.requiresEmailVerification) { |
54 | this.notificationsService.alert( | 58 | this.info = this.i18n('Welcome! Now please check your emails to verify your account and complete signup.') |
55 | this.i18n('Welcome'), | 59 | return |
56 | this.i18n('Please check your email to verify your account and complete signup.') | ||
57 | ) | ||
58 | } else { | ||
59 | this.notificationsService.success( | ||
60 | this.i18n('Success'), | ||
61 | this.i18n('Registration for {{username}} complete.', { username: userCreate.username }) | ||
62 | ) | ||
63 | } | 60 | } |
64 | this.redirectService.redirectToHomepage() | 61 | |
62 | // Auto login | ||
63 | this.authService.login(userCreate.username, userCreate.password) | ||
64 | .subscribe( | ||
65 | () => { | ||
66 | this.notifier.success(this.i18n('You are now logged in as {{username}}!', { username: userCreate.username })) | ||
67 | |||
68 | this.redirectService.redirectToHomepage() | ||
69 | }, | ||
70 | |||
71 | err => this.error = err.message | ||
72 | ) | ||
65 | }, | 73 | }, |
66 | 74 | ||
67 | err => this.error = err.message | 75 | err => this.error = err.message |