feat: ACL 관련 정리
This commit is contained in:
@@ -11,18 +11,35 @@ export type LoginCtx = {
|
||||
loginDate: Date;
|
||||
}
|
||||
|
||||
export function ReqACL<Q extends LoginCtx & SessionCtx>(action: ServerActionType): ProcDecorator<Q, Q> {
|
||||
return (ctx) => {
|
||||
if(ctx.allowServerAction?.has(action)){
|
||||
export function ReqACL<Q extends LoginCtx & SessionCtx>(...actions: ServerActionType[]): ()=>ProcDecorator<Q, Q> {
|
||||
return () => {
|
||||
return (ctx) => {
|
||||
if (actions.length === 0) {
|
||||
return [{
|
||||
result: true,
|
||||
}, ctx];
|
||||
}
|
||||
if(!ctx.allowServerAction){
|
||||
return [{
|
||||
result: false,
|
||||
type: 'Required ACL',
|
||||
info: 'No Server ACL in session context.'
|
||||
}, ctx];
|
||||
}
|
||||
|
||||
for (const action of actions) {
|
||||
if (!ctx.allowServerAction.has(action)) {
|
||||
return [{
|
||||
result: false,
|
||||
type: 'Required ACL',
|
||||
info: `NotEnoughPermission: ${action}`
|
||||
}, ctx];
|
||||
}
|
||||
}
|
||||
|
||||
return [{
|
||||
result: true,
|
||||
}, ctx];
|
||||
}
|
||||
|
||||
return [{
|
||||
result: false,
|
||||
type: 'Required ACL',
|
||||
info: `NotEnoughPermission: ${action}`
|
||||
}, ctx];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user