Skip to content

Commit

Permalink
Merge pull request #127 from menshutin/helper-bug
Browse files Browse the repository at this point in the history
Fix bug with object to array conversion
  • Loading branch information
dereuromark authored Oct 31, 2020
2 parents 9cefe91 + 5843a00 commit 8ee90f4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/View/Helper/AuthUserHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace TinyAuth\View\Helper;

use ArrayAccess;
use Cake\Core\Exception\Exception;
use Cake\Routing\Router;
use Cake\View\Helper;
Expand Down Expand Up @@ -75,8 +76,9 @@ public function hasAccess(array $url) {
if ($authUser === null && !$this->getConfig('includeAuthentication')) {
throw new Exception('Variable _authUser containing the user data needs to be passed down. The TinyAuth.Auth component does it automatically, if loaded.');
}
$userArray = ($authUser instanceof ArrayAccess && method_exists($authUser, 'toArray')) ? $authUser->toArray() : (array)$authUser;

return $this->_checkUser((array)$authUser, $url);
return $this->_checkUser($userArray, $url);
}

/**
Expand Down

0 comments on commit 8ee90f4

Please sign in to comment.