mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-09 20:12:10 +10:00
* feat: set lang in html head * fix: add # in front of git ref * fix: remove unused vars from example env * fix: package name and license field * fix: enable sourcemap for client and server * fix: emojis not showing in prod this is extremely cursed, but it works * chore: refactor auth manager * feat: disable invitations if simple auth disabled * feat: add drop version to footer * feat: translate auth endpoints * chore: move oidc module * feat: add weekly tasks enabled object cleanup as weekly task * feat: add timestamp to task log msgs * feat: add guard to prevent invalid progress % * fix: add missing global scope to i18n components * feat: set base url for i18n * feat: switch task log to json format * ci: run ci on develop branch only * fix: UserWidget text not updating #109 * fix: EXTERNAL_URL being computed at build * feat: add basic language outlines for translation * feat: add more english dialects
49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
import sessionHandler from "~/server/internal/session";
|
|
import authManager from "~/server/internal/auth";
|
|
|
|
defineRouteMeta({
|
|
openAPI: {
|
|
tags: ["Auth"],
|
|
description: "OIDC Signin callback",
|
|
parameters: [],
|
|
},
|
|
});
|
|
|
|
export default defineEventHandler(async (h3) => {
|
|
const enabledAuthManagers = authManager.getAuthProviders();
|
|
if (!enabledAuthManagers.OpenID) return sendRedirect(h3, "/auth/signin");
|
|
|
|
const manager = enabledAuthManagers.OpenID;
|
|
|
|
const query = getQuery(h3);
|
|
const code = query.code?.toString();
|
|
if (!code)
|
|
throw createError({
|
|
statusCode: 400,
|
|
statusMessage: "No code in query params.",
|
|
});
|
|
|
|
const state = query.state?.toString();
|
|
if (!state)
|
|
throw createError({
|
|
statusCode: 400,
|
|
statusMessage: "No state in query params.",
|
|
});
|
|
|
|
const result = await manager.authorize(code, state);
|
|
|
|
if (typeof result === "string")
|
|
throw createError({
|
|
statusCode: 403,
|
|
statusMessage: `Failed to sign in: "${result}". Please try again.`,
|
|
});
|
|
|
|
await sessionHandler.signin(h3, result.user.id, true);
|
|
|
|
if (result.options.redirect) {
|
|
return sendRedirect(h3, result.options.redirect);
|
|
}
|
|
|
|
return sendRedirect(h3, "/");
|
|
});
|