server/users: hardcode available ranks

This commit is contained in:
rr-
2016-05-08 16:59:25 +02:00
parent 58964bcdc9
commit 198cb0af3e
37 changed files with 359 additions and 383 deletions

View File

@ -11,6 +11,15 @@ class Api {
this.userName = null;
this.userPassword = null;
this.cache = {};
this.allRanks = [
'anonymous',
'restricted',
'regular',
'power',
'moderator',
'administrator',
'nobody',
];
}
get(url) {
@ -75,7 +84,7 @@ class Api {
continue;
}
const rankName = config.privileges[privilege];
const rankIndex = config.ranks.indexOf(rankName);
const rankIndex = this.allRanks.indexOf(rankName);
if (minViableRank === null || rankIndex < minViableRank) {
minViableRank = rankIndex;
}
@ -84,7 +93,7 @@ class Api {
console.error('Bad privilege name: ' + lookup);
}
let myRank = this.user !== null ?
config.ranks.indexOf(this.user.rank) :
this.allRanks.indexOf(this.user.rank) :
0;
return myRank >= minViableRank;
}