경로 이동

This commit is contained in:
2023-08-18 14:13:46 +00:00
parent df8b5e854b
commit aec88333c2
12 changed files with 33 additions and 33 deletions
+31
View File
@@ -0,0 +1,31 @@
import type { SessionCtx } from "./StartSession.js";
import type { ProcDecorator } from "./base.js";
export type LoginCtx = {
userID: number;
userName: string;
userLevel: number;
allowServerAction: Record<string, number>;
loginDate: Date;
}
export const loginCtxSessionKey = 'loginCtx';
export function ReqLogin<Q extends SessionCtx>(): ProcDecorator<LoginCtx & Q, Q> {
return (ctx) => {
const loginCtx = ctx.session.getItem<LoginCtx>(loginCtxSessionKey);
if(!loginCtx){
return [{
result: false,
type: 'Required Login',
info: 'ReqLogin'
}, ctx];
}
return [{
result: true,
},{
...loginCtx,
...ctx,
}];
}
}