throw errors for missing values
This commit is contained in:
parent
9779fb7e9d
commit
1fe34ef31d
@ -32,6 +32,8 @@ class UserDatabase extends AbstractUserDatabase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fetchUser (id, force = false) {
|
async fetchUser (id, force = false) {
|
||||||
|
|
||||||
|
if (!id) throw new Error('Missing token');
|
||||||
|
|
||||||
id = id.toString();
|
id = id.toString();
|
||||||
if (!force && this.cache.has(id)) return this.cache.get(id);
|
if (!force && this.cache.has(id)) return this.cache.get(id);
|
||||||
@ -49,6 +51,8 @@ class UserDatabase extends AbstractUserDatabase {
|
|||||||
|
|
||||||
async fetchApplication (id, force = false) {
|
async fetchApplication (id, force = false) {
|
||||||
|
|
||||||
|
if (!id) throw new Error('Missing token');
|
||||||
|
|
||||||
id = id.toString();
|
id = id.toString();
|
||||||
if (!force && this.cache.has(id)) return this.cache.get(id);
|
if (!force && this.cache.has(id)) return this.cache.get(id);
|
||||||
|
|
||||||
@ -60,9 +64,12 @@ class UserDatabase extends AbstractUserDatabase {
|
|||||||
this.cache.set(id, app);
|
this.cache.set(id, app);
|
||||||
|
|
||||||
return app;
|
return app;
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|
||||||
async findUser (username) {
|
async findUser (username) {
|
||||||
|
|
||||||
|
if (!username) throw new Error('Missing token');
|
||||||
|
|
||||||
let user = this.cache.find(u => u.username.toLowerCase() === username.toLowerCase());
|
let user = this.cache.find(u => u.username.toLowerCase() === username.toLowerCase());
|
||||||
if (user) return Promise.resolve(user);
|
if (user) return Promise.resolve(user);
|
||||||
@ -85,6 +92,7 @@ class UserDatabase extends AbstractUserDatabase {
|
|||||||
* @memberof UserDatabase
|
* @memberof UserDatabase
|
||||||
*/
|
*/
|
||||||
async matchToken (token) {
|
async matchToken (token) {
|
||||||
|
|
||||||
if (!token) throw new Error('Missing token');
|
if (!token) throw new Error('Missing token');
|
||||||
|
|
||||||
let app = this.cache.find(a => a.token.encrypted === token);
|
let app = this.cache.find(a => a.token.encrypted === token);
|
||||||
@ -100,6 +108,7 @@ class UserDatabase extends AbstractUserDatabase {
|
|||||||
user.attachApplication(app);
|
user.attachApplication(app);
|
||||||
|
|
||||||
return app;
|
return app;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user