diff options
Diffstat (limited to 'client/src/app')
9 files changed, 37 insertions, 6 deletions
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html b/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html index 03997ea40..1f542e458 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html +++ b/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html | |||
@@ -158,6 +158,20 @@ | |||
158 | 158 | ||
159 | <small i18n *ngIf="hasUnlimitedSignup()" class="text-muted">Signup won't be limited to a fixed number of users.</small> | 159 | <small i18n *ngIf="hasUnlimitedSignup()" class="text-muted">Signup won't be limited to a fixed number of users.</small> |
160 | </div> | 160 | </div> |
161 | |||
162 | <div [ngClass]="getDisabledSignupClass()" class="mt-3"> | ||
163 | <label i18n for="signupMinimumAge">Minimum required age to create an account</label> | ||
164 | |||
165 | <div class="number-with-unit"> | ||
166 | <input | ||
167 | type="number" min="1" id="signupMinimumAge" class="form-control" | ||
168 | formControlName="minimumAge" [ngClass]="{ 'input-error': formErrors['signup.minimumAge'] }" | ||
169 | > | ||
170 | <span i18n>{form.value['signup']['minimumAge'], plural, =1 {year old} other {years old}}</span> | ||
171 | </div> | ||
172 | |||
173 | <div *ngIf="formErrors.signup.minimumAge" class="form-error">{{ formErrors.signup.minimumAge }}</div> | ||
174 | </div> | ||
161 | </ng-container> | 175 | </ng-container> |
162 | </my-peertube-checkbox> | 176 | </my-peertube-checkbox> |
163 | </div> | 177 | </div> |
@@ -469,7 +483,7 @@ | |||
469 | <ng-container formGroupName="twitter"> | 483 | <ng-container formGroupName="twitter"> |
470 | 484 | ||
471 | <div class="form-group"> | 485 | <div class="form-group"> |
472 | <label i18n for="signupLimit">Your Twitter username</label> | 486 | <label for="servicesTwitterUsername" i18n>Your Twitter username</label> |
473 | 487 | ||
474 | <input | 488 | <input |
475 | type="text" id="servicesTwitterUsername" class="form-control" | 489 | type="text" id="servicesTwitterUsername" class="form-control" |
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.ts index d50148e7a..74fdb87a1 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.ts +++ b/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.ts | |||
@@ -1,4 +1,3 @@ | |||
1 | |||
2 | import { pairwise } from 'rxjs/operators' | 1 | import { pairwise } from 'rxjs/operators' |
3 | import { SelectOptionsItem } from 'src/types/select-options-item.model' | 2 | import { SelectOptionsItem } from 'src/types/select-options-item.model' |
4 | import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core' | 3 | import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core' |
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts index dc8334dd0..cb65ca6e7 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts +++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts | |||
@@ -21,6 +21,7 @@ import { | |||
21 | SEARCH_INDEX_URL_VALIDATOR, | 21 | SEARCH_INDEX_URL_VALIDATOR, |
22 | SERVICES_TWITTER_USERNAME_VALIDATOR, | 22 | SERVICES_TWITTER_USERNAME_VALIDATOR, |
23 | SIGNUP_LIMIT_VALIDATOR, | 23 | SIGNUP_LIMIT_VALIDATOR, |
24 | SIGNUP_MINIMUM_AGE_VALIDATOR, | ||
24 | TRANSCODING_THREADS_VALIDATOR | 25 | TRANSCODING_THREADS_VALIDATOR |
25 | } from '@app/shared/form-validators/custom-config-validators' | 26 | } from '@app/shared/form-validators/custom-config-validators' |
26 | import { USER_VIDEO_QUOTA_DAILY_VALIDATOR, USER_VIDEO_QUOTA_VALIDATOR } from '@app/shared/form-validators/user-validators' | 27 | import { USER_VIDEO_QUOTA_DAILY_VALIDATOR, USER_VIDEO_QUOTA_VALIDATOR } from '@app/shared/form-validators/user-validators' |
@@ -120,7 +121,8 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { | |||
120 | signup: { | 121 | signup: { |
121 | enabled: null, | 122 | enabled: null, |
122 | limit: SIGNUP_LIMIT_VALIDATOR, | 123 | limit: SIGNUP_LIMIT_VALIDATOR, |
123 | requiresEmailVerification: null | 124 | requiresEmailVerification: null, |
125 | minimumAge: SIGNUP_MINIMUM_AGE_VALIDATOR | ||
124 | }, | 126 | }, |
125 | import: { | 127 | import: { |
126 | videos: { | 128 | videos: { |
diff --git a/client/src/app/+signup/+register/register-step-terms.component.html b/client/src/app/+signup/+register/register-step-terms.component.html index 1cfdc0a3a..28a6e0021 100644 --- a/client/src/app/+signup/+register/register-step-terms.component.html +++ b/client/src/app/+signup/+register/register-step-terms.component.html | |||
@@ -2,8 +2,8 @@ | |||
2 | <div class="form-group form-group-terms"> | 2 | <div class="form-group form-group-terms"> |
3 | <my-peertube-checkbox inputName="terms" formControlName="terms"> | 3 | <my-peertube-checkbox inputName="terms" formControlName="terms"> |
4 | <ng-template ptTemplate="label"> | 4 | <ng-template ptTemplate="label"> |
5 | <ng-container i18n> | 5 | <ng-container i18n> |
6 | I am at least 16 years old and agree | 6 | I am at least {{ minimumAge }} years old and agree |
7 | to the <a class="terms-anchor" (click)="onTermsClick($event)" href='#'>Terms</a> | 7 | to the <a class="terms-anchor" (click)="onTermsClick($event)" href='#'>Terms</a> |
8 | <ng-container *ngIf="hasCodeOfConduct"> and to the <a (click)="onCodeOfConductClick($event)" href='#'>Code of Conduct</a></ng-container> | 8 | <ng-container *ngIf="hasCodeOfConduct"> and to the <a (click)="onCodeOfConductClick($event)" href='#'>Code of Conduct</a></ng-container> |
9 | of this instance | 9 | of this instance |
diff --git a/client/src/app/+signup/+register/register-step-terms.component.ts b/client/src/app/+signup/+register/register-step-terms.component.ts index db834c68d..20c1ae1c4 100644 --- a/client/src/app/+signup/+register/register-step-terms.component.ts +++ b/client/src/app/+signup/+register/register-step-terms.component.ts | |||
@@ -12,6 +12,7 @@ import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' | |||
12 | }) | 12 | }) |
13 | export class RegisterStepTermsComponent extends FormReactive implements OnInit { | 13 | export class RegisterStepTermsComponent extends FormReactive implements OnInit { |
14 | @Input() hasCodeOfConduct = false | 14 | @Input() hasCodeOfConduct = false |
15 | @Input() minimumAge = 16 | ||
15 | 16 | ||
16 | @Output() formBuilt = new EventEmitter<FormGroup>() | 17 | @Output() formBuilt = new EventEmitter<FormGroup>() |
17 | @Output() termsClick = new EventEmitter<void>() | 18 | @Output() termsClick = new EventEmitter<void>() |
diff --git a/client/src/app/+signup/+register/register.component.html b/client/src/app/+signup/+register/register.component.html index dc1c7496f..de72065d3 100644 --- a/client/src/app/+signup/+register/register.component.html +++ b/client/src/app/+signup/+register/register.component.html | |||
@@ -17,6 +17,7 @@ | |||
17 | 17 | ||
18 | <my-register-step-terms | 18 | <my-register-step-terms |
19 | [hasCodeOfConduct]="!!aboutHtml.codeOfConduct" | 19 | [hasCodeOfConduct]="!!aboutHtml.codeOfConduct" |
20 | [minimumAge]="minimumAge" | ||
20 | (formBuilt)="onTermsFormBuilt($event)" (termsClick)="onTermsClick()" (codeOfConductClick)="onCodeOfConductClick()" | 21 | (formBuilt)="onTermsFormBuilt($event)" (termsClick)="onTermsClick()" (codeOfConductClick)="onCodeOfConductClick()" |
21 | ></my-register-step-terms> | 22 | ></my-register-step-terms> |
22 | 23 | ||
diff --git a/client/src/app/+signup/+register/register.component.ts b/client/src/app/+signup/+register/register.component.ts index 8e89bb01a..241ca04c6 100644 --- a/client/src/app/+signup/+register/register.component.ts +++ b/client/src/app/+signup/+register/register.component.ts | |||
@@ -56,6 +56,10 @@ export class RegisterComponent implements OnInit { | |||
56 | return this.serverConfig.signup.requiresEmailVerification | 56 | return this.serverConfig.signup.requiresEmailVerification |
57 | } | 57 | } |
58 | 58 | ||
59 | get minimumAge () { | ||
60 | return this.serverConfig.signup.minimumAge | ||
61 | } | ||
62 | |||
59 | ngOnInit (): void { | 63 | ngOnInit (): void { |
60 | this.serverConfig = this.route.snapshot.data.serverConfig | 64 | this.serverConfig = this.route.snapshot.data.serverConfig |
61 | 65 | ||
diff --git a/client/src/app/core/server/server.service.ts b/client/src/app/core/server/server.service.ts index 5b1b7603f..6918957f4 100644 --- a/client/src/app/core/server/server.service.ts +++ b/client/src/app/core/server/server.service.ts | |||
@@ -60,7 +60,8 @@ export class ServerService { | |||
60 | signup: { | 60 | signup: { |
61 | allowed: false, | 61 | allowed: false, |
62 | allowedForCurrentIP: false, | 62 | allowedForCurrentIP: false, |
63 | requiresEmailVerification: false | 63 | requiresEmailVerification: false, |
64 | minimumAge: 16 | ||
64 | }, | 65 | }, |
65 | transcoding: { | 66 | transcoding: { |
66 | profile: 'default', | 67 | profile: 'default', |
diff --git a/client/src/app/shared/form-validators/custom-config-validators.ts b/client/src/app/shared/form-validators/custom-config-validators.ts index ef6e9b456..1ed5700ff 100644 --- a/client/src/app/shared/form-validators/custom-config-validators.ts +++ b/client/src/app/shared/form-validators/custom-config-validators.ts | |||
@@ -49,6 +49,15 @@ export const SIGNUP_LIMIT_VALIDATOR: BuildFormValidator = { | |||
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | export const SIGNUP_MINIMUM_AGE_VALIDATOR: BuildFormValidator = { | ||
53 | VALIDATORS: [Validators.required, Validators.min(1), Validators.pattern('[0-9]+')], | ||
54 | MESSAGES: { | ||
55 | 'required': $localize`Signup minimum age is required.`, | ||
56 | 'min': $localize`Signup minimum age must be greater than 1.`, | ||
57 | 'pattern': $localize`Signup minimum age must be a number.` | ||
58 | } | ||
59 | } | ||
60 | |||
52 | export const ADMIN_EMAIL_VALIDATOR: BuildFormValidator = { | 61 | export const ADMIN_EMAIL_VALIDATOR: BuildFormValidator = { |
53 | VALIDATORS: [Validators.required, Validators.email], | 62 | VALIDATORS: [Validators.required, Validators.email], |
54 | MESSAGES: { | 63 | MESSAGES: { |