diff --git a/src/server.ts b/src/server.ts index 7f655e3..21db01b 100644 --- a/src/server.ts +++ b/src/server.ts @@ -28,6 +28,20 @@ const oidcClaimsHook = async (orig: OidcAuth | undefined, claims: IDToken | unde }; }; +app.get("/auth/logout", async (c) => { + const auth = await getAuth(c); + if (!auth) { + return c.json({ status: 401, message: "Unauthorized" }, 401); + } + await revokeSession(c); + return c.json({ status: 200, message: "OK" }); +}); + +app.get("/auth/login", async (c) => { + const auth = await getAuth(c); + return c.json({ status: 200, message: "OK", data: auth }); +}); + app.get("/auth/callback", async (c: Context) => { c.set("oidcClaimsHook", oidcClaimsHook); return processOAuthCallback(c); @@ -44,20 +58,6 @@ app.use("/auth/*", async (c, next) => { await next(); }); -app.get("/auth/logout", async (c) => { - const auth = await getAuth(c); - if (!auth) { - return c.json({ status: 401, message: "Unauthorized" }, 401); - } - await revokeSession(c); - return c.json({ status: 200, message: "OK" }); -}); - -app.get("/auth/login", async (c) => { - const auth = await getAuth(c); - return c.json({ status: 200, message: "OK", data: auth }); -}); - app.route("/", api); app.get("/stats", async (c) => {