🔐 Fixing SSO bugs (#36)

This commit is contained in:
Montassar Ghanmy
2023-05-02 10:03:25 +01:00
committed by GitHub
parent fd03040d73
commit 3a94d7386e
5 changed files with 15 additions and 8 deletions
@@ -14,6 +14,7 @@ const jwtPlugin: FastifyPluginCallback = (fastify, _opts, next) => {
if (jwt.type === "refresh") {
// TODO in the future we must invalidate the refresh token (because it should be single use)
}
request.currentUser = {
...{ email: jwt.email },
...{ id: jwt.sub },
@@ -29,7 +30,7 @@ const jwtPlugin: FastifyPluginCallback = (fastify, _opts, next) => {
try {
await authenticate(request);
} catch (err) {
throw fastify.httpErrors.unauthorized("Bad credentials");
throw fastify.httpErrors.unauthorized(`Bad credentials ${JSON.stringify(err)}`);
}
});