ActivityPub-federated video streaming platform using P2P directly in your web browser
Add "agree to the terms" checkbox in registration form
Chocobozzzb4a929accf57
diff --git a/client/src/app/+about/about-instance/about-instance.component.html b/client/src/app/+about/about-instance/about-instance.component.htmlindex e433b0016b..5970cac016 100644--- a/client/src/app/+about/about-instance/about-instance.component.html+++ b/client/src/app/+about/about-instance/about-instance.component.html@@ -12,7 +12,7 @@<div [innerHTML]="descriptionHTML"></div></div>-<div class="terms">+<div class="terms" id="terms-section"><div i18n class="section-title">Terms</div><div [innerHTML]="termsHTML"></div>diff --git a/client/src/app/shared/forms/form-reactive.ts b/client/src/app/shared/forms/form-reactive.tsindex e4f7481b5a..0bb7d25e6f 100644--- a/client/src/app/shared/forms/form-reactive.ts+++ b/client/src/app/shared/forms/form-reactive.ts@@ -23,7 +23,7 @@ export abstract class FormReactive {this.formErrors = formErrorsthis.validationMessages = validationMessages- this.form.valueChanges.subscribe(data => this.onValueChanged(false))+ this.form.valueChanges.subscribe(() => this.onValueChanged(false))}protected onValueChanged (forceCheck = false) {diff --git a/client/src/app/shared/forms/form-validators/form-validator.service.ts b/client/src/app/shared/forms/form-validators/form-validator.service.tsindex d10e17ca76..19a8bef25c 100644--- a/client/src/app/shared/forms/form-validators/form-validator.service.ts+++ b/client/src/app/shared/forms/form-validators/form-validator.service.ts@@ -1,7 +1,6 @@import { FormBuilder, FormControl, FormGroup, ValidatorFn } from '@angular/forms'import { Injectable } from '@angular/core'import { FormReactiveErrors, FormReactiveValidationMessages } from '@app/shared/forms/form-reactive'-import { I18n } from '@ngx-translate/i18n-polyfill'export type BuildFormValidator = {VALIDATORS: ValidatorFn[],@@ -18,8 +17,7 @@ export type BuildFormDefaultValues = {export class FormValidatorService {constructor (- private formBuilder: FormBuilder,- private i18n: I18n+ private formBuilder: FormBuilder) {}buildForm (obj: BuildFormArgument, defaultValues: BuildFormDefaultValues = {}) {diff --git a/client/src/app/shared/forms/form-validators/user-validators.service.ts b/client/src/app/shared/forms/form-validators/user-validators.service.tsindex bb6ff20686..5edae2e380 100644--- a/client/src/app/shared/forms/form-validators/user-validators.service.ts+++ b/client/src/app/shared/forms/form-validators/user-validators.service.ts@@ -12,6 +12,7 @@ export class UserValidatorsService {readonly USER_ROLE: BuildFormValidatorreadonly USER_DISPLAY_NAME: BuildFormValidatorreadonly USER_DESCRIPTION: BuildFormValidator+ readonly USER_TERMS: BuildFormValidatorconstructor (private i18n: I18n) {@@ -89,5 +90,14 @@ export class UserValidatorsService {'maxlength': this.i18n('Description cannot be more than 250 characters long.')}}++ this.USER_TERMS = {+ VALIDATORS: [+ Validators.requiredTrue+ ],+ MESSAGES: {+ 'required': this.i18n('You must to agree with the instance terms in order to registering on it.')+ }+ }}}diff --git a/client/src/app/shared/forms/peertube-checkbox.component.html b/client/src/app/shared/forms/peertube-checkbox.component.htmlindex 820e7a6212..38691f0504 100644--- a/client/src/app/shared/forms/peertube-checkbox.component.html+++ b/client/src/app/shared/forms/peertube-checkbox.component.html@@ -3,6 +3,7 @@<input type="checkbox" [(ngModel)]="checked" (ngModelChange)="onModelChange()" [id]="inputName" [disabled]="isDisabled" /><span role="checkbox" [attr.aria-checked]="checked"></span><span *ngIf="labelText">{{ labelText }}</span>+ <span *ngIf="labelHtml" [innerHTML]="labelHtml"></span></label><my-help *ngIf="helpHtml" tooltipPlacement="top" helpType="custom" i18n-customHtml [customHtml]="helpHtml"></my-help>diff --git a/client/src/app/shared/forms/peertube-checkbox.component.ts b/client/src/app/shared/forms/peertube-checkbox.component.tsindex c626c4c5df..bbc9904dfe 100644--- a/client/src/app/shared/forms/peertube-checkbox.component.ts+++ b/client/src/app/shared/forms/peertube-checkbox.component.ts@@ -17,6 +17,7 @@ export class PeertubeCheckboxComponent implements ControlValueAccessor {@Input() checked = false@Input() inputName: string@Input() labelText: string+ @Input() labelHtml: string@Input() helpHtml: stringisDisabled = falsediff --git a/client/src/app/signup/signup.component.html b/client/src/app/signup/signup.component.htmlindex 2fe9a42818..565b695d92 100644--- a/client/src/app/signup/signup.component.html+++ b/client/src/app/signup/signup.component.html@@ -54,6 +54,17 @@</div></div>+ <div class="form-group form-group-terms">+ <my-peertube-checkbox+ inputName="terms" formControlName="terms"+ 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"+ ></my-peertube-checkbox>++ <div *ngIf="formErrors.terms" class="form-error">+ {{ formErrors.terms }}+ </div>+ </div>+<input type="submit" i18n-value value="Signup" [disabled]="!form.valid"></form>diff --git a/client/src/app/signup/signup.component.scss b/client/src/app/signup/signup.component.scssindex 8ea4ec997d..e6d4842979 100644--- a/client/src/app/signup/signup.component.scss+++ b/client/src/app/signup/signup.component.scss@@ -10,6 +10,9 @@}}+.form-group-terms {+ margin: 30px 0;+}input:not([type=submit]) {@include peertube-input-text(340px);diff --git a/client/src/app/signup/signup.component.ts b/client/src/app/signup/signup.component.tsindex 53d1445723..076dac4547 100644--- a/client/src/app/signup/signup.component.ts+++ b/client/src/app/signup/signup.component.ts@@ -38,7 +38,8 @@ export class SignupComponent extends FormReactive implements OnInit {this.buildForm({username: this.userValidatorsService.USER_USERNAME,password: this.userValidatorsService.USER_PASSWORD,- email: this.userValidatorsService.USER_EMAIL+ email: this.userValidatorsService.USER_EMAIL,+ terms: this.userValidatorsService.USER_TERMS})this.serverService.configLoaded