Skip to content

Commit 8feaf5c

Browse files
committed
api/api-keys: replace .find() with .some() in allowedServices
& also a little refactor
1 parent dce9eb3 commit 8feaf5c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

api/src/security/api-keys.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ const validateKeys = (input) => {
8080
}
8181

8282
if (details.allowedServices) {
83-
const isArray = Array.isArray(details.allowedServices);
84-
85-
if (isArray) {
86-
const invalid_services = details.allowedServices.find(service => !env.allServices.has(service));
83+
if (Array.isArray(details.allowedServices)) {
84+
const invalid_services = details.allowedServices.some(
85+
service => !env.allServices.has(service)
86+
);
8787
if (invalid_services) {
8888
throw "`allowedServices` in details contains an invalid service";
8989
}

0 commit comments

Comments
 (0)