import type { GatewayActionType, ServerActionType } from "../schema/gateway/User.js"; import type { SessionCtx } from "./StartSession.js"; import type { ProcDecorator } from "./base.js"; export type GatewayLoginCtx = { userID: number; userName: string; userLevel: number; allowServerAction: Map>; allowGatewayAction: Set; loginDate: Date; } export const loginCtxSessionKey = 'loginCtx'; export function ReqGatewayLogin(): 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, }]; } }