throw errors for missing values
This commit is contained in:
parent
9779fb7e9d
commit
1fe34ef31d
@ -33,6 +33,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);
|
||||
if (id.includes('temp')) return null;
|
||||
@ -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,10 +64,13 @@ 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;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user