diff options
-rw-r--r-- | client/src/app/+signup/+register/register.component.ts | 11 | ||||
-rw-r--r-- | client/src/app/core/plugins/plugin.service.ts | 3 | ||||
-rw-r--r-- | server/middlewares/validators/users.ts | 3 | ||||
-rw-r--r-- | shared/models/plugins/client-hook.model.ts | 10 | ||||
-rw-r--r-- | shared/models/plugins/plugin-client-scope.type.ts | 2 | ||||
-rw-r--r-- | shared/models/plugins/register-server-setting.model.ts | 3 |
6 files changed, 24 insertions, 8 deletions
diff --git a/client/src/app/+signup/+register/register.component.ts b/client/src/app/+signup/+register/register.component.ts index d470ef4dc..5a7215516 100644 --- a/client/src/app/+signup/+register/register.component.ts +++ b/client/src/app/+signup/+register/register.component.ts | |||
@@ -6,6 +6,7 @@ import { UserRegister } from '@shared/models/users/user-register.model' | |||
6 | import { FormGroup } from '@angular/forms' | 6 | import { FormGroup } from '@angular/forms' |
7 | import { About } from '@shared/models/server' | 7 | import { About } from '@shared/models/server' |
8 | import { InstanceService } from '@app/shared/instance/instance.service' | 8 | import { InstanceService } from '@app/shared/instance/instance.service' |
9 | import { HooksService } from '@app/core/plugins/hooks.service' | ||
9 | import { NgbAccordion } from '@ng-bootstrap/ng-bootstrap' | 10 | import { NgbAccordion } from '@ng-bootstrap/ng-bootstrap' |
10 | 11 | ||
11 | @Component({ | 12 | @Component({ |
@@ -41,6 +42,7 @@ export class RegisterComponent implements OnInit { | |||
41 | private serverService: ServerService, | 42 | private serverService: ServerService, |
42 | private redirectService: RedirectService, | 43 | private redirectService: RedirectService, |
43 | private instanceService: InstanceService, | 44 | private instanceService: InstanceService, |
45 | private hooks: HooksService, | ||
44 | private i18n: I18n | 46 | private i18n: I18n |
45 | ) { | 47 | ) { |
46 | } | 48 | } |
@@ -60,6 +62,8 @@ export class RegisterComponent implements OnInit { | |||
60 | 62 | ||
61 | err => this.notifier.error(err.message) | 63 | err => this.notifier.error(err.message) |
62 | ) | 64 | ) |
65 | |||
66 | this.hooks.runAction('action:signup.register.init', 'signup') | ||
63 | } | 67 | } |
64 | 68 | ||
65 | hasSameChannelAndAccountNames () { | 69 | hasSameChannelAndAccountNames () { |
@@ -94,10 +98,13 @@ export class RegisterComponent implements OnInit { | |||
94 | if (this.accordion) this.accordion.toggle('code-of-conduct') | 98 | if (this.accordion) this.accordion.toggle('code-of-conduct') |
95 | } | 99 | } |
96 | 100 | ||
97 | signup () { | 101 | async signup () { |
98 | this.error = null | 102 | this.error = null |
99 | 103 | ||
100 | const body: UserRegister = Object.assign(this.formStepUser.value, { channel: this.formStepChannel.value }) | 104 | const body: UserRegister = await this.hooks.wrapObject( |
105 | Object.assign(this.formStepUser.value, { channel: this.formStepChannel.value }), | ||
106 | 'filter:api.signup.registration.create.params' | ||
107 | ) | ||
101 | 108 | ||
102 | this.userService.signup(body).subscribe( | 109 | this.userService.signup(body).subscribe( |
103 | () => { | 110 | () => { |
diff --git a/client/src/app/core/plugins/plugin.service.ts b/client/src/app/core/plugins/plugin.service.ts index 3af36765a..52ba4215a 100644 --- a/client/src/app/core/plugins/plugin.service.ts +++ b/client/src/app/core/plugins/plugin.service.ts | |||
@@ -42,7 +42,8 @@ export class PluginService implements ClientHook { | |||
42 | pluginsLoaded: { [ scope in PluginClientScope ]: ReplaySubject<boolean> } = { | 42 | pluginsLoaded: { [ scope in PluginClientScope ]: ReplaySubject<boolean> } = { |
43 | common: new ReplaySubject<boolean>(1), | 43 | common: new ReplaySubject<boolean>(1), |
44 | search: new ReplaySubject<boolean>(1), | 44 | search: new ReplaySubject<boolean>(1), |
45 | 'video-watch': new ReplaySubject<boolean>(1) | 45 | 'video-watch': new ReplaySubject<boolean>(1), |
46 | signup: new ReplaySubject<boolean>(1) | ||
46 | } | 47 | } |
47 | 48 | ||
48 | translationsObservable: Observable<PluginTranslation> | 49 | translationsObservable: Observable<PluginTranslation> |
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts index 8615de406..c78c67a8c 100644 --- a/server/middlewares/validators/users.ts +++ b/server/middlewares/validators/users.ts | |||
@@ -283,7 +283,8 @@ const usersVideoRatingValidator = [ | |||
283 | const ensureUserRegistrationAllowed = [ | 283 | const ensureUserRegistrationAllowed = [ |
284 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | 284 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { |
285 | const allowedParams = { | 285 | const allowedParams = { |
286 | body: req.body | 286 | body: req.body, |
287 | ip: req.ip | ||
287 | } | 288 | } |
288 | 289 | ||
289 | const allowedResult = await Hooks.wrapPromiseFun( | 290 | const allowedResult = await Hooks.wrapPromiseFun( |
diff --git a/shared/models/plugins/client-hook.model.ts b/shared/models/plugins/client-hook.model.ts index 07ea7eb96..91167ff8c 100644 --- a/shared/models/plugins/client-hook.model.ts +++ b/shared/models/plugins/client-hook.model.ts | |||
@@ -38,7 +38,10 @@ export const clientFilterHookObject = { | |||
38 | 'filter:api.search.videos.list.result': true, | 38 | 'filter:api.search.videos.list.result': true, |
39 | // Filter params/result of the function that fetch video-channels according to the user search | 39 | // Filter params/result of the function that fetch video-channels according to the user search |
40 | 'filter:api.search.video-channels.list.params': true, | 40 | 'filter:api.search.video-channels.list.params': true, |
41 | 'filter:api.search.video-channels.list.result': true | 41 | 'filter:api.search.video-channels.list.result': true, |
42 | |||
43 | // Filter form | ||
44 | 'filter:api.signup.registration.create.params': true | ||
42 | } | 45 | } |
43 | 46 | ||
44 | export type ClientFilterHookName = keyof typeof clientFilterHookObject | 47 | export type ClientFilterHookName = keyof typeof clientFilterHookObject |
@@ -58,7 +61,10 @@ export const clientActionHookObject = { | |||
58 | 'action:search.init': true, | 61 | 'action:search.init': true, |
59 | 62 | ||
60 | // Fired every time Angular URL changes | 63 | // Fired every time Angular URL changes |
61 | 'action:router.navigation-end': true | 64 | 'action:router.navigation-end': true, |
65 | |||
66 | // Fired when the registration page is being initialized | ||
67 | 'action:signup.register.init': true | ||
62 | } | 68 | } |
63 | 69 | ||
64 | export type ClientActionHookName = keyof typeof clientActionHookObject | 70 | export type ClientActionHookName = keyof typeof clientActionHookObject |
diff --git a/shared/models/plugins/plugin-client-scope.type.ts b/shared/models/plugins/plugin-client-scope.type.ts index 0c616c5ed..1c6d884f0 100644 --- a/shared/models/plugins/plugin-client-scope.type.ts +++ b/shared/models/plugins/plugin-client-scope.type.ts | |||
@@ -1 +1 @@ | |||
export type PluginClientScope = 'common' | 'video-watch' | 'search' | export type PluginClientScope = 'common' | 'video-watch' | 'search' | 'signup' | ||
diff --git a/shared/models/plugins/register-server-setting.model.ts b/shared/models/plugins/register-server-setting.model.ts index 78c5abd1b..65a181705 100644 --- a/shared/models/plugins/register-server-setting.model.ts +++ b/shared/models/plugins/register-server-setting.model.ts | |||
@@ -3,7 +3,8 @@ export interface RegisterServerSettingOptions { | |||
3 | label: string | 3 | label: string |
4 | type: 'input' | 4 | type: 'input' |
5 | 5 | ||
6 | // If the setting is not private, anyone can view its value | 6 | // If the setting is not private, anyone can view its value (client code included) |
7 | // If the setting is private, only server-side hooks can access it | ||
7 | // Mainly used by the PeerTube client to get admin config | 8 | // Mainly used by the PeerTube client to get admin config |
8 | private: boolean | 9 | private: boolean |
9 | 10 | ||