From c50eb29e39cc193338f6b60d3b109fcc31cddf2b Mon Sep 17 00:00:00 2001 From: rijkvanzanten Date: Tue, 13 Oct 2020 16:48:32 -0400 Subject: [PATCH] Fix ip check for public role --- api/src/middleware/check-ip.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/src/middleware/check-ip.ts b/api/src/middleware/check-ip.ts index 85d0736a34..5fd9e269ac 100644 --- a/api/src/middleware/check-ip.ts +++ b/api/src/middleware/check-ip.ts @@ -9,7 +9,8 @@ export const checkIP: RequestHandler = asyncHandler(async (req, res, next) => { .from('directus_roles') .where({ id: req.accountability!.role }) .first(); - const ipAllowlist = (role.ip_access || '').split(',').filter((ip: string) => ip); + + const ipAllowlist = (role?.ip_access || '').split(',').filter((ip: string) => ip); if (ipAllowlist.length > 0 && ipAllowlist.includes(req.accountability!.ip) === false) throw new InvalidIPException();