}
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) {