diff options
author | Lucas Declercq <lucas-dclrcq@users.noreply.github.com> | 2018-10-10 08:57:00 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-10-10 08:57:00 +0200 |
commit | 9ccff23877ec8d740fcd5a9254fcd2424b62d2c8 (patch) | |
tree | 03a47436ce88a3169aed491439517001ab773bb6 /client/src | |
parent | ee7c25c767c357bd12570889f8ccd79ba9ea4eb9 (diff) | |
download | PeerTube-9ccff23877ec8d740fcd5a9254fcd2424b62d2c8.tar.gz PeerTube-9ccff23877ec8d740fcd5a9254fcd2424b62d2c8.tar.zst PeerTube-9ccff23877ec8d740fcd5a9254fcd2424b62d2c8.zip |
Add explicit error message that changing video ownership only works with local accounts (#1214)
* Add explicit error message that changing video ownership only works with local accounts
* Remove superfluous logger
* Remove unneeded end() to error responses
* Add a message on client side to prevent transfering ownership to a remote account
Diffstat (limited to 'client/src')
-rw-r--r-- | client/src/app/shared/forms/form-validators/video-change-ownership-validators.service.ts | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/client/src/app/shared/forms/form-validators/video-change-ownership-validators.service.ts b/client/src/app/shared/forms/form-validators/video-change-ownership-validators.service.ts index 087b80b44..c6fbb7538 100644 --- a/client/src/app/shared/forms/form-validators/video-change-ownership-validators.service.ts +++ b/client/src/app/shared/forms/form-validators/video-change-ownership-validators.service.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { I18n } from '@ngx-translate/i18n-polyfill' | 1 | import { I18n } from '@ngx-translate/i18n-polyfill' |
2 | import { Validators } from '@angular/forms' | 2 | import { AbstractControl, ValidationErrors, Validators } from '@angular/forms' |
3 | import { Injectable } from '@angular/core' | 3 | import { Injectable } from '@angular/core' |
4 | import { BuildFormValidator } from '@app/shared' | 4 | import { BuildFormValidator } from '@app/shared' |
5 | 5 | ||
@@ -9,10 +9,19 @@ export class VideoChangeOwnershipValidatorsService { | |||
9 | 9 | ||
10 | constructor (private i18n: I18n) { | 10 | constructor (private i18n: I18n) { |
11 | this.USERNAME = { | 11 | this.USERNAME = { |
12 | VALIDATORS: [ Validators.required ], | 12 | VALIDATORS: [ Validators.required, this.localAccountValidator ], |
13 | MESSAGES: { | 13 | MESSAGES: { |
14 | 'required': this.i18n('The username is required.') | 14 | 'required': this.i18n('The username is required.'), |
15 | 'localAccountOnly': this.i18n('You can only transfer ownership to a local account') | ||
15 | } | 16 | } |
16 | } | 17 | } |
17 | } | 18 | } |
19 | |||
20 | localAccountValidator (control: AbstractControl): ValidationErrors { | ||
21 | if (control.value.includes('@')) { | ||
22 | return { 'localAccountOnly': true } | ||
23 | } | ||
24 | |||
25 | return null | ||
26 | } | ||
18 | } | 27 | } |