diff --git a/@sammo/server/src/procDecorator/ReqACL.ts b/@sammo/server/src/procDecorator/ReqACL.ts new file mode 100644 index 0000000..bea1d9b --- /dev/null +++ b/@sammo/server/src/procDecorator/ReqACL.ts @@ -0,0 +1,28 @@ +import type { SessionCtx } from "@sammo/server_util"; +import type { ProcDecorator } from "@strpc/express/proc_decorator"; +import type { ServerActionType } from "@sammo/gateway_server/exports" +import { loginCtxSessionKey } from "./ReqLogin.js"; + +export type LoginCtx = { + userID: number; + userName: string; + userLevel: number; + allowServerAction?: Set; + loginDate: Date; +} + +export function ReqACL(action: ServerActionType): ProcDecorator { + return (ctx) => { + if(ctx.allowServerAction?.has(action)){ + return [{ + result: true, + }, ctx]; + } + + return [{ + result: false, + type: 'Required ACL', + info: `NotEnoughPermission: ${action}` + }, ctx]; + } +} \ No newline at end of file