Home
/
browser-rts.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ed54ffb
)
bugfix: don't crash on invalid session
author
xangelo
<git@xangelo.ca>
Fri, 27 May 2022 17:44:56 +0000
(13:44 -0400)
committer
xangelo
<git@xangelo.ca>
Fri, 27 May 2022 17:44:56 +0000
(13:44 -0400)
src/repository/accounts.ts
patch
|
blob
|
history
diff --git
a/src/repository/accounts.ts
b/src/repository/accounts.ts
index e74b81aadea4102909c563b08a08c49052377d5d..2ea621d3c3b0ff0a59987c333e09b551e8d7cde2 100644
(file)
--- a/
src/repository/accounts.ts
+++ b/
src/repository/accounts.ts
@@
-39,14
+39,18
@@
export class AccountRepository extends Repository<Account> {
}
async validate(accountId: string, token: string): Promise<Account> {
}
async validate(accountId: string, token: string): Promise<Account> {
- const session = await this.session.validate(accountId, token);
- const account = await this.FindOne({id: session.account_id});
+ try {
+ const session = await this.session.validate(accountId, token);
+ const account = await this.FindOne({id: session.account_id});
- if(!account) {
- throw new NotFoundError('User not found', ERROR_CODE.USER_NOT_FOUND);
- }
-
- return account;
+ if(!account) {
+ throw new NotFoundError('User not found', ERROR_CODE.USER_NOT_FOUND);
+ }
+ return account;
+ }
+ catch(e) {
+ throw new NotFoundError('User not found', ERROR_CODE.INVALID_USER_TOKEN);
+ }
}
async create(username: string, password: string) {
}
async create(username: string, password: string) {