mirror of
https://github.com/documenso/documenso.git
synced 2025-11-12 15:53:02 +10:00
🔒️ 401 if no user could be found from token
This commit is contained in:
@ -12,12 +12,12 @@ export async function getUserFromToken(
|
||||
const tokenEmail = token?.email?.toString();
|
||||
|
||||
if (!token) {
|
||||
res.status(401).send("No token found for request.");
|
||||
res.status(401).send("No session token found for request.");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!tokenEmail) {
|
||||
res.status(400).send("No email found in token.");
|
||||
res.status(400).send("No email found in session token.");
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -25,5 +25,10 @@ export async function getUserFromToken(
|
||||
where: { email: tokenEmail },
|
||||
});
|
||||
|
||||
if (!user) {
|
||||
res.status(401).end();
|
||||
return null;
|
||||
}
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user