Skip to content

Commit 005e64e

Browse files
committed
valite auth/access rules in backend
1 parent e9e5d29 commit 005e64e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

backend/internal/access-list.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ const internalAccessList = {
2525
create: (access, data) => {
2626
return access.can('access_lists:create', data)
2727
.then((/*access_data*/) => {
28+
if ((typeof data.items === 'undefined' || !data.items.length) && (typeof data.clients === 'undefined' || !data.clients.length)) {
29+
throw new error.InternalValidationError('At leaste one user/pass or address must be defined');
30+
}
31+
2832
return accessListModel
2933
.query()
3034
.omit(omissions())
@@ -110,6 +114,10 @@ const internalAccessList = {
110114
update: (access, data) => {
111115
return access.can('access_lists:update', data.id)
112116
.then((/*access_data*/) => {
117+
if ((typeof data.items === 'undefined' || !data.items.length) && (typeof data.clients === 'undefined' || !data.clients.length)) {
118+
throw new error.InternalValidationError('At leaste one user/pass or address must be defined');
119+
}
120+
113121
return internalAccessList.get(access, {id: data.id});
114122
})
115123
.then((row) => {

0 commit comments

Comments
 (0)