Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F3010165
access-control.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
549 B
Referenced Files
None
Subscribers
None
access-control.ts
View Options
import
{
Context
}
from
"koa"
;
import
{
ActionName
,
Collection
}
from
"sealious"
;
export
function
peopleWhoCan
(
action
:
ActionName
,
collection
:
Collection
)
{
return
async
function
(
ctx
:
Context
)
{
const
policy
=
collection
.
getPolicy
(
action
);
const
result
=
await
policy
.
check
(
ctx
.
$context
);
if
(
!
result
)
{
ctx
.
status
=
403
;
return
{
canAccess
:
false
,
message
:
"Not allowed"
};
}
if
(
!
result
.
allowed
)
{
ctx
.
status
=
403
;
return
{
canAccess
:
false
,
message
:
result
.
reason
};
}
return
{
canAccess
:
true
,
message
:
""
};
};
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Wed, May 7, 19:37 (1 d, 21 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
624873
Default Alt Text
access-control.ts (549 B)
Attached To
Mode
rSGEN sealgen
Attached
Detach File
Event Timeline
Log In to Comment