From 1d5342abc43df02cf0bd69b1e865c0f179182eef Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 29 May 2019 11:03:01 +0200 Subject: Multi step registration --- server/middlewares/validators/users.ts | 6 ++++++ server/tests/api/check-params/users.ts | 7 +++++++ 2 files changed, 13 insertions(+) (limited to 'server') diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts index b58dcc0d6..7a081af33 100644 --- a/server/middlewares/validators/users.ts +++ b/server/middlewares/validators/users.ts @@ -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) diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts index d26032ea5..95097817b 100644 --- a/server/tests/api/check-params/users.ts +++ b/server/tests/api/check-params/users.ts @@ -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) -- cgit v1.2.3