reserve the "admin" username

This commit is contained in:
Girish Ramakrishnan
2016-04-13 16:50:20 -07:00
parent c24d7e7b3c
commit ed78bd05c8
10 changed files with 13 additions and 9 deletions

View File

@@ -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;
}