import { Redis } from '../../lib/redis'
import { UserModel } from '../../models/account/user'
import { areValidationErrors } from './utils'
+import { ActorModel } from '../../models/activitypub/actor'
const usersAddValidator = [
body('username').custom(isUserUsernameValid).withMessage('Should have a valid username (lowercase alphanumeric characters)'),
return false
}
+ const actor = await ActorModel.loadLocalByName(username)
+ if (actor) {
+ res.status(409)
+ .send({ error: 'Another actor (account/channel) with this name already exists.' })
+ .end()
+ return false
+ }
+
return true
}
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
})
+ it('Should fail with a "peertube" username', async function () {
+ const fields = immutableAssign(baseCorrectParams, { username: 'peertube' })
+
+ await makePostBodyRequest({
+ url: server.url,
+ path,
+ token: server.accessToken,
+ fields,
+ statusCodeExpected: 409
+ })
+ })
+
it('Should succeed with the correct params', async function () {
await makePostBodyRequest({
url: server.url,
})
})
+ it('Should fail with a "peertube" username', async function () {
+ const fields = immutableAssign(baseCorrectParams, { username: 'peertube' })
+
+ await makePostBodyRequest({
+ url: server.url,
+ path: registrationPath,
+ token: server.accessToken,
+ fields,
+ statusCodeExpected: 409
+ })
+ })
+
it('Should fail if we register a user with the same email', async function () {
const fields = immutableAssign(baseCorrectParams, { email: 'admin1@example.com' })