aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/middlewares/validators/users.ts6
-rw-r--r--server/tests/api/check-params/users.ts7
2 files changed, 13 insertions, 0 deletions
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 = [
70 .end() 70 .end()
71 } 71 }
72 72
73 if (body.channel.name === body.username) {
74 return res.status(400)
75 .send({ error: 'Channel name cannot be the same than user username.' })
76 .end()
77 }
78
73 const existing = await ActorModel.loadLocalByName(body.channel.name) 79 const existing = await ActorModel.loadLocalByName(body.channel.name)
74 if (existing) { 80 if (existing) {
75 return res.status(409) 81 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 () {
737 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields }) 737 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
738 }) 738 })
739 739
740 it('Should fail with a channel name that is the same than user username', async function () {
741 const source = { username: 'super_user', channel: { name: 'super_user', displayName: 'display name' } }
742 const fields = immutableAssign(baseCorrectParams, source)
743
744 await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
745 })
746
740 it('Should fail with an existing channel', async function () { 747 it('Should fail with an existing channel', async function () {
741 const videoChannelAttributesArg = { name: 'existing_channel', displayName: 'hello', description: 'super description' } 748 const videoChannelAttributesArg = { name: 'existing_channel', displayName: 'hello', description: 'super description' }
742 await addVideoChannel(server.url, server.accessToken, videoChannelAttributesArg) 749 await addVideoChannel(server.url, server.accessToken, videoChannelAttributesArg)