import { FormGroup } from '@angular/forms'
import { About } from '@shared/models/server'
import { InstanceService } from '@app/shared/instance/instance.service'
+import { HooksService } from '@app/core/plugins/hooks.service'
import { NgbAccordion } from '@ng-bootstrap/ng-bootstrap'
@Component({
private serverService: ServerService,
private redirectService: RedirectService,
private instanceService: InstanceService,
+ private hooks: HooksService,
private i18n: I18n
) {
}
err => this.notifier.error(err.message)
)
+
+ this.hooks.runAction('action:signup.register.init', 'signup')
}
hasSameChannelAndAccountNames () {
if (this.accordion) this.accordion.toggle('code-of-conduct')
}
- signup () {
+ async signup () {
this.error = null
- const body: UserRegister = Object.assign(this.formStepUser.value, { channel: this.formStepChannel.value })
+ const body: UserRegister = await this.hooks.wrapObject(
+ Object.assign(this.formStepUser.value, { channel: this.formStepChannel.value }),
+ 'filter:api.signup.registration.create.params'
+ )
this.userService.signup(body).subscribe(
() => {
pluginsLoaded: { [ scope in PluginClientScope ]: ReplaySubject<boolean> } = {
common: new ReplaySubject<boolean>(1),
search: new ReplaySubject<boolean>(1),
- 'video-watch': new ReplaySubject<boolean>(1)
+ 'video-watch': new ReplaySubject<boolean>(1),
+ signup: new ReplaySubject<boolean>(1)
}
translationsObservable: Observable<PluginTranslation>
const ensureUserRegistrationAllowed = [
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
const allowedParams = {
- body: req.body
+ body: req.body,
+ ip: req.ip
}
const allowedResult = await Hooks.wrapPromiseFun(
'filter:api.search.videos.list.result': true,
// Filter params/result of the function that fetch video-channels according to the user search
'filter:api.search.video-channels.list.params': true,
- 'filter:api.search.video-channels.list.result': true
+ 'filter:api.search.video-channels.list.result': true,
+
+ // Filter form
+ 'filter:api.signup.registration.create.params': true
}
export type ClientFilterHookName = keyof typeof clientFilterHookObject
'action:search.init': true,
// Fired every time Angular URL changes
- 'action:router.navigation-end': true
+ 'action:router.navigation-end': true,
+
+ // Fired when the registration page is being initialized
+ 'action:signup.register.init': true
}
export type ClientActionHookName = keyof typeof clientActionHookObject
-export type PluginClientScope = 'common' | 'video-watch' | 'search'
+export type PluginClientScope = 'common' | 'video-watch' | 'search' | 'signup'
label: string
type: 'input'
- // If the setting is not private, anyone can view its value
+ // If the setting is not private, anyone can view its value (client code included)
+ // If the setting is private, only server-side hooks can access it
// Mainly used by the PeerTube client to get admin config
private: boolean