mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 08:13:56 +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();
|
const tokenEmail = token?.email?.toString();
|
||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
res.status(401).send("No token found for request.");
|
res.status(401).send("No session token found for request.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tokenEmail) {
|
if (!tokenEmail) {
|
||||||
res.status(400).send("No email found in token.");
|
res.status(400).send("No email found in session token.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,5 +25,10 @@ export async function getUserFromToken(
|
|||||||
where: { email: tokenEmail },
|
where: { email: tokenEmail },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!user) {
|
||||||
|
res.status(401).end();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user