Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F7862395
dispatcher-wrapper.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
dispatcher-wrapper.js
View Options
var
Set
=
require
(
"Set"
);
function
DispatcherWrapper
(
real_dispatcher
,
allowed_chip_longids
){
this
.
real_dispatcher
=
real_dispatcher
;
this
.
allowed_chip_longids
=
new
Set
();
this
.
allowed_chip_longids
.
addAll
(
allowed_chip_longids
);
var
functions_to_copy
=
[
"resources_get_access_mode"
,
"resources_edit_resource_access_mode"
,
"resources_get_by_id"
,
"users_create_user"
,
"users_get_user_data"
,
"users_password_match"
,
"users_user_exists"
,
"database_query"
];
for
(
var
i
in
functions_to_copy
){
this
[
functions_to_copy
[
i
]]
=
this
.
real_dispatcher
[
functions_to_copy
[
i
]];
}
}
DispatcherWrapper
.
prototype
=
new
function
(){
var
that
=
this
;
this
.
resources_list_by_type
=
function
(
type_name
){
if
(
this
.
can_access
(
"resource_type."
+
type_name
)){
return
this
.
real_dispatcher
.
resources_list_by_type
(
type_name
);
}
else
{
throw
new
Error
(
"cannot access chip: resource_type."
+
type_name
);
}
}
this
.
resources_create
=
function
(
type_name
,
body
){
if
(
this
.
can_access
(
"resource_type."
+
type_name
)){
return
this
.
real_dispatcher
.
resources_create
.
apply
(
this
.
real_dispatcher
,
arguments
);
}
else
{
throw
new
Error
(
"cannot access chip: resource_type."
+
type_name
);
}
}
this
.
resources_delete
=
function
(
type_name
,
body
){
if
(
this
.
can_access
(
"resource_type."
+
type_name
)){
return
this
.
real_dispatcher
.
resources_delete
.
apply
(
this
.
real_dispatcher
,
arguments
);
}
}
this
.
can_access
=
function
(
requested_chip_longid
){
if
(
this
.
allowed_chip_longids
.
has
(
"resource_type.*"
)
&&
requested_chip_longid
.
indexOf
(
"resource_type"
)
===
0
)
{
return
true
;
}
else
{
return
this
.
allowed_chip_longids
.
has
(
requested_chip_longid
);
}
}
}
module
.
exports
=
DispatcherWrapper
;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Aug 13, 20:27 (23 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
877042
Default Alt Text
dispatcher-wrapper.js (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment