import type { ServerActionType } from "../schema/gateway/User.js"; import type { SessionCtx } from "./StartSession.js"; import type { ProcDecorator } from "./base.js"; export type LoginCtx = { userID: number; userName: string; userLevel: number; allowServerAction?: Set; loginDate: Date; } export const loginCtxSessionKey = 'loginCtx'; export function ReqLogin(): ProcDecorator { return (ctx) => { const loginCtx = ctx.session.getItem(loginCtxSessionKey); if(!loginCtx){ return [{ result: false, type: 'Required Login', info: 'ReqLogin' }, ctx]; } return [{ result: true, },{ ...loginCtx, ...ctx, }]; } }