chore: implemented feedback

This commit is contained in:
Catalin Pit
2023-12-14 11:05:39 +02:00
parent e79d385534
commit 19736ce60b
3 changed files with 22 additions and 8 deletions

View File

@ -15,13 +15,13 @@ export const checkUserFromToken = async ({ token }: { token: string }) => {
});
if (!user) {
throw new Error('Token not found');
throw new Error('Invalid token');
}
const tokenObject = user.ApiToken.find((apiToken) => apiToken.token === token);
if (!tokenObject || new Date(tokenObject.expires) < new Date()) {
throw new Error('The API token has expired');
throw new Error('Expired token');
}
return user;