aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/signup/signup.component.ts
diff options
context:
space:
mode:
authorJosh Morel <morel.josh@hotmail.com>2018-08-31 03:18:19 -0400
committerChocobozzz <me@florianbigard.com>2018-08-31 09:18:19 +0200
commitd9eaee3939bf2e93e5d775d32bce77842201faba (patch)
treec115acb3611986b98f51b3addf29ebe66f63ee7f /client/src/app/signup/signup.component.ts
parent04291e1ba44032165388758e993d385a10c1c5a1 (diff)
downloadPeerTube-d9eaee3939bf2e93e5d775d32bce77842201faba.tar.gz
PeerTube-d9eaee3939bf2e93e5d775d32bce77842201faba.tar.zst
PeerTube-d9eaee3939bf2e93e5d775d32bce77842201faba.zip
add user account email verificiation (#977)
* add user account email verificiation includes server and client code to: * enable verificationRequired via custom config * send verification email with registration * ask for verification email * verify via email * prevent login if not verified and required * conditional client links to ask for new verification email * allow login for verified=null these are users created when verification not required should still be able to login when verification is enabled * refactor email verifcation pr * change naming from verified to emailVerified * change naming from askVerifyEmail to askSendVerifyEmail * undo unrelated automatic prettier formatting on api/config * use redirectService for home * remove redundant success notification on email verified * revert test.yaml smpt host
Diffstat (limited to 'client/src/app/signup/signup.component.ts')
-rw-r--r--client/src/app/signup/signup.component.ts22
1 files changed, 17 insertions, 5 deletions
diff --git a/client/src/app/signup/signup.component.ts b/client/src/app/signup/signup.component.ts
index 47f9bc6f4..16e444678 100644
--- a/client/src/app/signup/signup.component.ts
+++ b/client/src/app/signup/signup.component.ts
@@ -3,7 +3,7 @@ import { Router } from '@angular/router'
3import { NotificationsService } from 'angular2-notifications' 3import { NotificationsService } from 'angular2-notifications'
4import { UserCreate } from '../../../../shared' 4import { UserCreate } from '../../../../shared'
5import { FormReactive, UserService, UserValidatorsService } from '../shared' 5import { FormReactive, UserService, UserValidatorsService } from '../shared'
6import { RedirectService } from '@app/core' 6import { RedirectService, ServerService } from '@app/core'
7import { I18n } from '@ngx-translate/i18n-polyfill' 7import { I18n } from '@ngx-translate/i18n-polyfill'
8import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' 8import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
9 9
@@ -21,6 +21,7 @@ export class SignupComponent extends FormReactive implements OnInit {
21 private router: Router, 21 private router: Router,
22 private notificationsService: NotificationsService, 22 private notificationsService: NotificationsService,
23 private userService: UserService, 23 private userService: UserService,
24 private serverService: ServerService,
24 private redirectService: RedirectService, 25 private redirectService: RedirectService,
25 private i18n: I18n 26 private i18n: I18n
26 ) { 27 ) {
@@ -31,6 +32,10 @@ export class SignupComponent extends FormReactive implements OnInit {
31 return window.location.host 32 return window.location.host
32 } 33 }
33 34
35 get requiresEmailVerification () {
36 return this.serverService.getConfig().signup.requiresEmailVerification
37 }
38
34 ngOnInit () { 39 ngOnInit () {
35 this.buildForm({ 40 this.buildForm({
36 username: this.userValidatorsService.USER_USERNAME, 41 username: this.userValidatorsService.USER_USERNAME,
@@ -47,10 +52,17 @@ export class SignupComponent extends FormReactive implements OnInit {
47 52
48 this.userService.signup(userCreate).subscribe( 53 this.userService.signup(userCreate).subscribe(
49 () => { 54 () => {
50 this.notificationsService.success( 55 if (this.requiresEmailVerification) {
51 this.i18n('Success'), 56 this.notificationsService.alert(
52 this.i18n('Registration for {{username}} complete.', { username: userCreate.username }) 57 this.i18n('Welcome'),
53 ) 58 this.i18n('Please check your email to verify your account and complete signup.')
59 )
60 } else {
61 this.notificationsService.success(
62 this.i18n('Success'),
63 this.i18n('Registration for {{username}} complete.', { username: userCreate.username })
64 )
65 }
54 this.redirectService.redirectToHomepage() 66 this.redirectService.redirectToHomepage()
55 }, 67 },
56 68