Multi step registration

This commit is contained in:
Chocobozzz
2019-05-29 11:03:01 +02:00
parent e590b4a512
commit 1d5342abc4
19 changed files with 502 additions and 93 deletions

View File

@@ -70,6 +70,12 @@ const usersRegisterValidator = [
.end()
}
if (body.channel.name === body.username) {
return res.status(400)
.send({ error: 'Channel name cannot be the same than user username.' })
.end()
}
const existing = await ActorModel.loadLocalByName(body.channel.name)
if (existing) {
return res.status(409)

View File

@@ -737,6 +737,13 @@ describe('Test users API validators', function () {
await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
})
it('Should fail with a channel name that is the same than user username', async function () {
const source = { username: 'super_user', channel: { name: 'super_user', displayName: 'display name' } }
const fields = immutableAssign(baseCorrectParams, source)
await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
})
it('Should fail with an existing channel', async function () {
const videoChannelAttributesArg = { name: 'existing_channel', displayName: 'hello', description: 'super description' }
await addVideoChannel(server.url, server.accessToken, videoChannelAttributesArg)