Merge reserved groups and usernames into one list
This is because now the mailbox names are shared
This commit is contained in:
@@ -87,17 +87,13 @@ UserError.BAD_TOKEN = 'Bad token';
|
||||
|
||||
function validateUsername(username) {
|
||||
assert.strictEqual(typeof username, 'string');
|
||||
// https://github.com/gogits/gogs/blob/52c8f691630548fe091d30bcfe8164545a05d3d5/models/repo.go#L393
|
||||
// admin@fqdn is also reservd for sending emails
|
||||
var RESERVED_USERNAMES = [ 'admin', 'no-reply', 'postmaster', 'mailer-daemon' ]; // apps like wordpress, gogs don't like these
|
||||
|
||||
// allow empty usernames
|
||||
if (username === '') return null;
|
||||
|
||||
if (username.length <= 1) return new UserError(UserError.BAD_FIELD, 'Username must be atleast 2 chars');
|
||||
if (username.length > 256) return new UserError(UserError.BAD_FIELD, 'Username too long');
|
||||
|
||||
if (RESERVED_USERNAMES.indexOf(username) !== -1) return new UserError(UserError.BAD_FIELD, 'Username is reserved');
|
||||
if (constants.RESERVED_NAMES.indexOf(username) !== -1) return new UserError(UserError.BAD_FIELD, 'Username is reserved');
|
||||
|
||||
// +/- can be tricky in emails
|
||||
if (/[^a-zA-Z0-9.]/.test(username)) return new UserError(UserError.BAD_FIELD, 'Username can only contain alphanumerals and dot');
|
||||
|
||||
Reference in New Issue
Block a user