fix: openid redirect auth query

This commit is contained in:
DecDuck
2025-05-15 21:22:24 +10:00
parent 8e3ae01a30
commit ce27f76856
4 changed files with 36 additions and 10 deletions

View File

@ -21,15 +21,19 @@ export default defineEventHandler(async (h3) => {
statusMessage: "No state in query params.",
});
const user = await manager.authorize(code, state);
const result = await manager.authorize(code, state);
if (typeof user === "string")
if (typeof result === "string")
throw createError({
statusCode: 403,
statusMessage: `Failed to sign in: "${user}". Please try again.`,
statusMessage: `Failed to sign in: "${result}". Please try again.`,
});
await sessionHandler.signin(h3, user.id, true);
await sessionHandler.signin(h3, result.user.id, true);
if (result.options.redirect) {
return sendRedirect(h3, result.options.redirect);
}
return sendRedirect(h3, "/");
});