Page MenuHomeSealhub

logout.redirect.ts
No OneTemporary

logout.redirect.ts

import type { Context } from "koa";
import { Mountable } from "@sealcode/sealgen";
import type 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) => {
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, 16:50 (1 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
598733
Default Alt Text
logout.redirect.ts (841 B)

Event Timeline