valite auth/access rules in backend

This commit is contained in:
Kyle Klaus 2020-04-13 19:23:55 -07:00
parent e9e5d293cc
commit 005e64eb9f

View File

@ -25,6 +25,10 @@ const internalAccessList = {
create: (access, data) => { create: (access, data) => {
return access.can('access_lists:create', data) return access.can('access_lists:create', data)
.then((/*access_data*/) => { .then((/*access_data*/) => {
if ((typeof data.items === 'undefined' || !data.items.length) && (typeof data.clients === 'undefined' || !data.clients.length)) {
throw new error.InternalValidationError('At leaste one user/pass or address must be defined');
}
return accessListModel return accessListModel
.query() .query()
.omit(omissions()) .omit(omissions())
@ -110,6 +114,10 @@ const internalAccessList = {
update: (access, data) => { update: (access, data) => {
return access.can('access_lists:update', data.id) return access.can('access_lists:update', data.id)
.then((/*access_data*/) => { .then((/*access_data*/) => {
if ((typeof data.items === 'undefined' || !data.items.length) && (typeof data.clients === 'undefined' || !data.clients.length)) {
throw new error.InternalValidationError('At leaste one user/pass or address must be defined');
}
return internalAccessList.get(access, {id: data.id}); return internalAccessList.get(access, {id: data.id});
}) })
.then((row) => { .then((row) => {