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;