diff --git a/src/server/components/UserDatabase.js b/src/server/components/UserDatabase.js index b4044d4..fcaab99 100644 --- a/src/server/components/UserDatabase.js +++ b/src/server/components/UserDatabase.js @@ -32,6 +32,8 @@ class UserDatabase extends AbstractUserDatabase { } async fetchUser (id, force = false) { + + if (!id) throw new Error('Missing token'); id = id.toString(); if (!force && this.cache.has(id)) return this.cache.get(id); @@ -49,6 +51,8 @@ class UserDatabase extends AbstractUserDatabase { async fetchApplication (id, force = false) { + if (!id) throw new Error('Missing token'); + id = id.toString(); if (!force && this.cache.has(id)) return this.cache.get(id); @@ -60,9 +64,12 @@ class UserDatabase extends AbstractUserDatabase { this.cache.set(id, app); return app; - } + + } async findUser (username) { + + if (!username) throw new Error('Missing token'); let user = this.cache.find(u => u.username.toLowerCase() === username.toLowerCase()); if (user) return Promise.resolve(user); @@ -85,6 +92,7 @@ class UserDatabase extends AbstractUserDatabase { * @memberof UserDatabase */ async matchToken (token) { + if (!token) throw new Error('Missing token'); let app = this.cache.find(a => a.token.encrypted === token); @@ -100,6 +108,7 @@ class UserDatabase extends AbstractUserDatabase { user.attachApplication(app); return app; + } /**