mirror of
https://github.com/MrTalon63/NeoMap.git
synced 2026-01-11 20:09:13 +01:00
Compare commits
No commits in common. "97101cfcc3a5d29c5dd15e47f3c878d16fade060" and "067594e669dfffd66ab09d54dd8d434ccb699a02" have entirely different histories.
97101cfcc3
...
067594e669
1 changed files with 16 additions and 15 deletions
|
|
@ -28,15 +28,6 @@ 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/callback", async (c: Context) => {
|
||||
c.set("oidcClaimsHook", oidcClaimsHook);
|
||||
return processOAuthCallback(c);
|
||||
|
|
@ -45,6 +36,22 @@ app.get("/auth/callback", async (c: Context) => {
|
|||
app.use(logger(), compress());
|
||||
app.use("/", serveStatic({ root: "./public" }));
|
||||
app.use("/auth/*", oidcAuthMiddleware());
|
||||
app.use("/auth/*", async (c, next) => {
|
||||
const auth = await getAuth(c);
|
||||
if (!auth) {
|
||||
return c.json({ status: 401, message: "Unauthorized" }, 401);
|
||||
}
|
||||
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);
|
||||
|
|
@ -93,12 +100,6 @@ app.get("/stats", async (c) => {
|
|||
});
|
||||
|
||||
app.onError((err, c) => {
|
||||
const isDev = Deno.env.get("NODE_ENV") === "development";
|
||||
if (isDev) {
|
||||
console.error(err);
|
||||
console.log(Deno.env.toObject());
|
||||
return c.json({ status: 500, message: "Server Error", error: err.message }, 500);
|
||||
}
|
||||
return c.json({ status: 500, message: "Server Error" }, 500);
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue