aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html16
-rw-r--r--client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.ts1
-rw-r--r--client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts4
-rw-r--r--client/src/app/+signup/+register/register-step-terms.component.html4
-rw-r--r--client/src/app/+signup/+register/register-step-terms.component.ts1
-rw-r--r--client/src/app/+signup/+register/register.component.html1
-rw-r--r--client/src/app/+signup/+register/register.component.ts4
-rw-r--r--client/src/app/core/server/server.service.ts3
-rw-r--r--client/src/app/shared/form-validators/custom-config-validators.ts9
-rw-r--r--config/default.yaml1
-rw-r--r--config/production.yaml.example1
-rw-r--r--server/controllers/api/config.ts3
-rw-r--r--server/initializers/checker-before-init.ts2
-rw-r--r--server/initializers/config.ts1
-rw-r--r--server/lib/server-config-manager.ts1
-rw-r--r--server/middlewares/validators/config.ts1
-rw-r--r--server/tests/api/check-params/config.ts3
-rw-r--r--server/tests/api/server/config.ts5
-rw-r--r--shared/extra-utils/server/config.ts3
-rw-r--r--shared/models/server/custom-config.model.ts1
-rw-r--r--shared/models/server/server-config.model.ts1
21 files changed, 55 insertions, 11 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
2import { pairwise } from 'rxjs/operators' 1import { pairwise } from 'rxjs/operators'
3import { SelectOptionsItem } from 'src/types/select-options-item.model' 2import { SelectOptionsItem } from 'src/types/select-options-item.model'
4import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core' 3import { 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'
26import { USER_VIDEO_QUOTA_DAILY_VALIDATOR, USER_VIDEO_QUOTA_VALIDATOR } from '@app/shared/form-validators/user-validators' 27import { 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})
13export class RegisterStepTermsComponent extends FormReactive implements OnInit { 13export 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
52export 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
52export const ADMIN_EMAIL_VALIDATOR: BuildFormValidator = { 61export const ADMIN_EMAIL_VALIDATOR: BuildFormValidator = {
53 VALIDATORS: [Validators.required, Validators.email], 62 VALIDATORS: [Validators.required, Validators.email],
54 MESSAGES: { 63 MESSAGES: {
diff --git a/config/default.yaml b/config/default.yaml
index 9b90bacfc..2a281f6c3 100644
--- a/config/default.yaml
+++ b/config/default.yaml
@@ -229,6 +229,7 @@ contact_form:
229signup: 229signup:
230 enabled: false 230 enabled: false
231 limit: 10 # When the limit is reached, registrations are disabled. -1 == unlimited 231 limit: 10 # When the limit is reached, registrations are disabled. -1 == unlimited
232 minimum_age: 16 # Used to configure the signup form
232 requires_email_verification: false 233 requires_email_verification: false
233 filters: 234 filters:
234 cidr: # You can specify CIDR ranges to whitelist (empty = no filtering) or blacklist 235 cidr: # You can specify CIDR ranges to whitelist (empty = no filtering) or blacklist
diff --git a/config/production.yaml.example b/config/production.yaml.example
index 47ef47279..42293b843 100644
--- a/config/production.yaml.example
+++ b/config/production.yaml.example
@@ -239,6 +239,7 @@ contact_form:
239signup: 239signup:
240 enabled: false 240 enabled: false
241 limit: 10 # When the limit is reached, registrations are disabled. -1 == unlimited 241 limit: 10 # When the limit is reached, registrations are disabled. -1 == unlimited
242 mimimum_age: 16
242 requires_email_verification: false 243 requires_email_verification: false
243 filters: 244 filters:
244 cidr: # You can specify CIDR ranges to whitelist (empty = no filtering) or blacklist 245 cidr: # You can specify CIDR ranges to whitelist (empty = no filtering) or blacklist
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts
index c9b5c8047..1f2a5f2da 100644
--- a/server/controllers/api/config.ts
+++ b/server/controllers/api/config.ts
@@ -174,7 +174,8 @@ function customConfig (): CustomConfig {
174 signup: { 174 signup: {
175 enabled: CONFIG.SIGNUP.ENABLED, 175 enabled: CONFIG.SIGNUP.ENABLED,
176 limit: CONFIG.SIGNUP.LIMIT, 176 limit: CONFIG.SIGNUP.LIMIT,
177 requiresEmailVerification: CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION 177 requiresEmailVerification: CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION,
178 minimumAge: CONFIG.SIGNUP.MINIMUM_AGE
178 }, 179 },
179 admin: { 180 admin: {
180 email: CONFIG.ADMIN.EMAIL 181 email: CONFIG.ADMIN.EMAIL
diff --git a/server/initializers/checker-before-init.ts b/server/initializers/checker-before-init.ts
index 2864b0287..93c019121 100644
--- a/server/initializers/checker-before-init.ts
+++ b/server/initializers/checker-before-init.ts
@@ -19,7 +19,7 @@ function checkMissedConfig () {
19 'csp.enabled', 'csp.report_only', 'csp.report_uri', 19 'csp.enabled', 'csp.report_only', 'csp.report_uri',
20 'security.frameguard.enabled', 20 'security.frameguard.enabled',
21 'cache.previews.size', 'cache.captions.size', 'cache.torrents.size', 'admin.email', 'contact_form.enabled', 21 'cache.previews.size', 'cache.captions.size', 'cache.torrents.size', 'admin.email', 'contact_form.enabled',
22 'signup.enabled', 'signup.limit', 'signup.requires_email_verification', 22 'signup.enabled', 'signup.limit', 'signup.requires_email_verification', 'signup.minimum_age',
23 'signup.filters.cidr.whitelist', 'signup.filters.cidr.blacklist', 23 'signup.filters.cidr.whitelist', 'signup.filters.cidr.blacklist',
24 'redundancy.videos.strategies', 'redundancy.videos.check_interval', 24 'redundancy.videos.strategies', 'redundancy.videos.check_interval',
25 'transcoding.enabled', 'transcoding.threads', 'transcoding.allow_additional_extensions', 'transcoding.hls.enabled', 25 'transcoding.enabled', 'transcoding.threads', 'transcoding.allow_additional_extensions', 'transcoding.hls.enabled',
diff --git a/server/initializers/config.ts b/server/initializers/config.ts
index 5281d3a66..30a9823b9 100644
--- a/server/initializers/config.ts
+++ b/server/initializers/config.ts
@@ -185,6 +185,7 @@ const CONFIG = {
185 get ENABLED () { return config.get<boolean>('signup.enabled') }, 185 get ENABLED () { return config.get<boolean>('signup.enabled') },
186 get LIMIT () { return config.get<number>('signup.limit') }, 186 get LIMIT () { return config.get<number>('signup.limit') },
187 get REQUIRES_EMAIL_VERIFICATION () { return config.get<boolean>('signup.requires_email_verification') }, 187 get REQUIRES_EMAIL_VERIFICATION () { return config.get<boolean>('signup.requires_email_verification') },
188 get MINIMUM_AGE () { return config.get<number>('signup.minimum_age') },
188 FILTERS: { 189 FILTERS: {
189 CIDR: { 190 CIDR: {
190 get WHITELIST () { return config.get<string[]>('signup.filters.cidr.whitelist') }, 191 get WHITELIST () { return config.get<string[]>('signup.filters.cidr.whitelist') },
diff --git a/server/lib/server-config-manager.ts b/server/lib/server-config-manager.ts
index 1aff6f446..25a770c6b 100644
--- a/server/lib/server-config-manager.ts
+++ b/server/lib/server-config-manager.ts
@@ -216,6 +216,7 @@ class ServerConfigManager {
216 const signup = { 216 const signup = {
217 allowed, 217 allowed,
218 allowedForCurrentIP, 218 allowedForCurrentIP,
219 minimumAge: CONFIG.SIGNUP.MINIMUM_AGE,
219 requiresEmailVerification: CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION 220 requiresEmailVerification: CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION
220 } 221 }
221 222
diff --git a/server/middlewares/validators/config.ts b/server/middlewares/validators/config.ts
index a85883b19..e3e0c2058 100644
--- a/server/middlewares/validators/config.ts
+++ b/server/middlewares/validators/config.ts
@@ -30,6 +30,7 @@ const customConfigUpdateValidator = [
30 body('signup.enabled').isBoolean().withMessage('Should have a valid signup enabled boolean'), 30 body('signup.enabled').isBoolean().withMessage('Should have a valid signup enabled boolean'),
31 body('signup.limit').isInt().withMessage('Should have a valid signup limit'), 31 body('signup.limit').isInt().withMessage('Should have a valid signup limit'),
32 body('signup.requiresEmailVerification').isBoolean().withMessage('Should have a valid requiresEmailVerification boolean'), 32 body('signup.requiresEmailVerification').isBoolean().withMessage('Should have a valid requiresEmailVerification boolean'),
33 body('signup.minimumAge').isInt().withMessage("Should have a valid minimum age required"),
33 34
34 body('admin.email').isEmail().withMessage('Should have a valid administrator email'), 35 body('admin.email').isEmail().withMessage('Should have a valid administrator email'),
35 body('contactForm.enabled').isBoolean().withMessage('Should have a valid contact form enabled boolean'), 36 body('contactForm.enabled').isBoolean().withMessage('Should have a valid contact form enabled boolean'),
diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts
index 004aa65b3..9549070ef 100644
--- a/server/tests/api/check-params/config.ts
+++ b/server/tests/api/check-params/config.ts
@@ -73,7 +73,8 @@ describe('Test config API validators', function () {
73 signup: { 73 signup: {
74 enabled: false, 74 enabled: false,
75 limit: 5, 75 limit: 5,
76 requiresEmailVerification: false 76 requiresEmailVerification: false,
77 minimumAge: 16
77 }, 78 },
78 admin: { 79 admin: {
79 email: 'superadmin1@example.com' 80 email: 'superadmin1@example.com'
diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts
index 1d9ea31df..19bf9582c 100644
--- a/server/tests/api/server/config.ts
+++ b/server/tests/api/server/config.ts
@@ -60,6 +60,7 @@ function checkInitialConfig (server: ServerInfo, data: CustomConfig) {
60 60
61 expect(data.signup.enabled).to.be.true 61 expect(data.signup.enabled).to.be.true
62 expect(data.signup.limit).to.equal(4) 62 expect(data.signup.limit).to.equal(4)
63 expect(data.signup.minimumAge).to.equal(16)
63 expect(data.signup.requiresEmailVerification).to.be.false 64 expect(data.signup.requiresEmailVerification).to.be.false
64 65
65 expect(data.admin.email).to.equal('admin' + server.internalServerNumber + '@example.com') 66 expect(data.admin.email).to.equal('admin' + server.internalServerNumber + '@example.com')
@@ -151,6 +152,7 @@ function checkUpdatedConfig (data: CustomConfig) {
151 expect(data.signup.enabled).to.be.false 152 expect(data.signup.enabled).to.be.false
152 expect(data.signup.limit).to.equal(5) 153 expect(data.signup.limit).to.equal(5)
153 expect(data.signup.requiresEmailVerification).to.be.false 154 expect(data.signup.requiresEmailVerification).to.be.false
155 expect(data.signup.minimumAge).to.equal(10)
154 156
155 // We override admin email in parallel tests, so skip this exception 157 // We override admin email in parallel tests, so skip this exception
156 if (parallelTests() === false) { 158 if (parallelTests() === false) {
@@ -316,7 +318,8 @@ describe('Test config', function () {
316 signup: { 318 signup: {
317 enabled: false, 319 enabled: false,
318 limit: 5, 320 limit: 5,
319 requiresEmailVerification: false 321 requiresEmailVerification: false,
322 minimumAge: 10
320 }, 323 },
321 admin: { 324 admin: {
322 email: 'superadmin1@example.com' 325 email: 'superadmin1@example.com'
diff --git a/shared/extra-utils/server/config.ts b/shared/extra-utils/server/config.ts
index b70110852..9fcfb31fd 100644
--- a/shared/extra-utils/server/config.ts
+++ b/shared/extra-utils/server/config.ts
@@ -98,7 +98,8 @@ function updateCustomSubConfig (url: string, token: string, newConfig: DeepParti
98 signup: { 98 signup: {
99 enabled: false, 99 enabled: false,
100 limit: 5, 100 limit: 5,
101 requiresEmailVerification: false 101 requiresEmailVerification: false,
102 minimumAge: 16
102 }, 103 },
103 admin: { 104 admin: {
104 email: 'superadmin1@example.com' 105 email: 'superadmin1@example.com'
diff --git a/shared/models/server/custom-config.model.ts b/shared/models/server/custom-config.model.ts
index 0bccd63e3..75d04423a 100644
--- a/shared/models/server/custom-config.model.ts
+++ b/shared/models/server/custom-config.model.ts
@@ -69,6 +69,7 @@ export interface CustomConfig {
69 enabled: boolean 69 enabled: boolean
70 limit: number 70 limit: number
71 requiresEmailVerification: boolean 71 requiresEmailVerification: boolean
72 minimumAge: number
72 } 73 }
73 74
74 admin: { 75 admin: {
diff --git a/shared/models/server/server-config.model.ts b/shared/models/server/server-config.model.ts
index 1667bc0e2..585e99aca 100644
--- a/shared/models/server/server-config.model.ts
+++ b/shared/models/server/server-config.model.ts
@@ -84,6 +84,7 @@ export interface ServerConfig {
84 allowed: boolean 84 allowed: boolean
85 allowedForCurrentIP: boolean 85 allowedForCurrentIP: boolean
86 requiresEmailVerification: boolean 86 requiresEmailVerification: boolean
87 minimumAge: number
87 } 88 }
88 89
89 transcoding: { 90 transcoding: {