valid user types config
This commit is contained in:
parent
4298972248
commit
e164756886
@ -14,6 +14,7 @@ class UserDatabase extends AbstractUserDatabase {
|
||||
this.logger = server.createLogger(this);
|
||||
this.cache = new Collection();
|
||||
this.collection = null;
|
||||
User.setValidTypes(validUserTypes);
|
||||
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,8 @@ class User {
|
||||
|
||||
static defaultPermissions = {};
|
||||
|
||||
static validTypes = [];
|
||||
|
||||
constructor (db, data) {
|
||||
|
||||
this._db = db;
|
||||
@ -11,6 +13,7 @@ class User {
|
||||
this.name = data.name;
|
||||
|
||||
if (!data.type) throw new Error('Missing type for user');
|
||||
if (User.validTypes.length && !User.validTypes.includes(data.type)) throw new Error('Invalid user type');
|
||||
this.type = data.type;
|
||||
|
||||
this.externalProfiles = data.externalProfiles || {};
|
||||
@ -55,6 +58,10 @@ class User {
|
||||
};
|
||||
}
|
||||
|
||||
static setValidTypes (types) {
|
||||
User.validTypes = types;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = User;
|
Loading…
Reference in New Issue
Block a user