Page MenuHomeSealhub

session.ts
No OneTemporary

session.ts

import Router = require("@koa/router");
import parseBody from "../parse-body";
const sessionRouter = new Router();
sessionRouter.post("/", parseBody(), async (ctx) => {
const username = ctx.request.body.username;
const password = ctx.request.body.password;
const session_id = await ctx.$app.collections.sessions.login(
username,
password
);
ctx.body = { status: "logged in!" };
ctx.status = 201;
const config = ctx.$app.ConfigManager.get("www-server");
const cookie_name = config["session-cookie-name"];
ctx.cookies.set(cookie_name, session_id, {
maxAge: 1000 * 60 * 60 * 24 * 7,
secure: ctx.request.protocol === "https",
overwrite: true,
});
});
export default sessionRouter;

File Metadata

Mime Type
text/x-java
Expires
Fri, Jan 24, 10:37 (1 d, 17 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
601595
Default Alt Text
session.ts (700 B)

Event Timeline