reserve the "admin" username
This commit is contained in:
@@ -75,6 +75,8 @@ UserError.BAD_TOKEN = 'Bad token';
|
||||
|
||||
function validateUsername(username) {
|
||||
assert.strictEqual(typeof username, 'string');
|
||||
// https://github.com/gogits/gogs/blob/52c8f691630548fe091d30bcfe8164545a05d3d5/models/repo.go#L393
|
||||
var RESERVED_USERNAMES = [ 'admin' ]; // apps like wordpress, gogs don't like these
|
||||
|
||||
// allow empty usernames
|
||||
if (username === '') return null;
|
||||
@@ -82,6 +84,8 @@ function validateUsername(username) {
|
||||
if (username.length <= 2) return new UserError(UserError.BAD_USERNAME, 'Username must be atleast 3 chars');
|
||||
if (username.length > 256) return new UserError(UserError.BAD_USERNAME, 'Username too long');
|
||||
|
||||
if (RESERVED_USERNAMES.indexOf(username) !== -1) return new UserError(UserError.BAD_USERNAME, 'Username is reserved');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user