From 99472a585d9d4ac153f097e698ab53505524ae14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Mon, 14 Oct 2024 13:57:09 +0900 Subject: [PATCH] cfmgrv4 init...2 --- app/Filters/AuthFilter.php | 4 ++-- app/Libraries/MyAuth/MyAuth.php | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/Filters/AuthFilter.php b/app/Filters/AuthFilter.php index 079a0a3..1db9f5b 100644 --- a/app/Filters/AuthFilter.php +++ b/app/Filters/AuthFilter.php @@ -33,8 +33,8 @@ class AuthFilter implements FilterInterface $auth->pushCurrentUrl($request->getUri()->getPath()); return redirect()->to(URLS['LOGIN'])->with('error', '로그인을하셔야합니다.'); } - //User Role 비교 // 회원 ROLES이 필요ROLE($arguments[0]) 목록에 존재하지 않으면(ACL) - if (!$auth->isAccessRole($arguments[0])) { + //User Role 비교 // 회원 ROLES이 필요ROLE($arguments) 목록에 존재하지 않으면(ACL) + if (!$auth->isAccessRole($arguments)) { // dd($auth->popPreviousUrl()); return redirect()->back()->with( 'error', diff --git a/app/Libraries/MyAuth/MyAuth.php b/app/Libraries/MyAuth/MyAuth.php index 0b56211..f54ec8d 100644 --- a/app/Libraries/MyAuth/MyAuth.php +++ b/app/Libraries/MyAuth/MyAuth.php @@ -30,13 +30,14 @@ class MyAuth extends CommonLibrary { return $this->getSession()->has(SESSION_NAMES['ISLOGIN']); } - final public function isAccessRole(string $role): bool + final public function isAccessRole(array $roles): bool { if ($this->getAuthInfo('role') === "") { return false; } - $roles = explode(DEFAULTS['DELIMITER_ROLE'], $this->getAuthInfo('role')); - if (!in_array($role, $roles)) { + $myRoles = explode(DEFAULTS['DELIMITER_ROLE'], $this->getAuthInfo('role')); + // 교집합이 없으면 false + if (empty(array_intersect($myRoles, $roles))) { return false; } return true;