mirror of
https://github.com/MrTalon63/NeoMap.git
synced 2026-01-11 11:59:13 +01:00
Compare commits
4 commits
067594e669
...
97101cfcc3
| Author | SHA1 | Date | |
|---|---|---|---|
| 97101cfcc3 | |||
| 101efa2605 | |||
| 6986ab1ec5 | |||
| 89825059a8 |
1 changed files with 15 additions and 16 deletions
|
|
@ -28,22 +28,6 @@ const oidcClaimsHook = async (orig: OidcAuth | undefined, claims: IDToken | unde
|
|||
};
|
||||
};
|
||||
|
||||
app.get("/auth/callback", async (c: Context) => {
|
||||
c.set("oidcClaimsHook", oidcClaimsHook);
|
||||
return processOAuthCallback(c);
|
||||
});
|
||||
|
||||
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) {
|
||||
|
|
@ -53,6 +37,15 @@ app.get("/auth/logout", async (c) => {
|
|||
return c.json({ status: 200, message: "OK" });
|
||||
});
|
||||
|
||||
app.get("/auth/callback", async (c: Context) => {
|
||||
c.set("oidcClaimsHook", oidcClaimsHook);
|
||||
return processOAuthCallback(c);
|
||||
});
|
||||
|
||||
app.use(logger(), compress());
|
||||
app.use("/", serveStatic({ root: "./public" }));
|
||||
app.use("/auth/*", oidcAuthMiddleware());
|
||||
|
||||
app.get("/auth/login", async (c) => {
|
||||
const auth = await getAuth(c);
|
||||
return c.json({ status: 200, message: "OK", data: auth });
|
||||
|
|
@ -100,6 +93,12 @@ 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