Page MenuHomeSealhub

logout.redirect.ts
No OneTemporary

logout.redirect.ts

import { Context } from "koa";
import { Mountable } from "@sealcode/sealgen";
import Router from "@koa/router";
export const actionName = "Logout";
export default new (class LogoutRedirect extends Mountable {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async canAccess(_: Context) {
return { canAccess: true, message: "" };
}
mount(router: Router, path: string) {
router.get(path, async (ctx) => {
console.log("logout.redirect.ts:15");
try {
const session_id = ctx.cookies.get("sealious-session");
if (session_id) {
await ctx.$app.collections.sessions.logout(
new ctx.$app.SuperContext(),
session_id
);
ctx.status = 302;
ctx.redirect("/");
} else {
ctx.status = 302;
ctx.redirect("/");
}
} catch (error) {
console.error("Error during logout:", error);
}
});
}
})();

File Metadata

Mime Type
text/x-java
Expires
Fri, Jan 24, 13:18 (1 d, 19 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
601599
Default Alt Text
logout.redirect.ts (872 B)

Event Timeline