valid user types config

This commit is contained in:
Erik 2022-11-09 17:11:19 +02:00
parent 4298972248
commit e164756886
Signed by: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB
2 changed files with 8 additions and 0 deletions

View File

@ -14,6 +14,7 @@ class UserDatabase extends AbstractUserDatabase {
this.logger = server.createLogger(this); this.logger = server.createLogger(this);
this.cache = new Collection(); this.cache = new Collection();
this.collection = null; this.collection = null;
User.setValidTypes(validUserTypes);
} }

View File

@ -2,6 +2,8 @@ class User {
static defaultPermissions = {}; static defaultPermissions = {};
static validTypes = [];
constructor (db, data) { constructor (db, data) {
this._db = db; this._db = db;
@ -11,6 +13,7 @@ class User {
this.name = data.name; this.name = data.name;
if (!data.type) throw new Error('Missing type for user'); 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.type = data.type;
this.externalProfiles = data.externalProfiles || {}; this.externalProfiles = data.externalProfiles || {};
@ -55,6 +58,10 @@ class User {
}; };
} }
static setValidTypes (types) {
User.validTypes = types;
}
} }
module.exports = User; module.exports = User;