Skip to content

Commit

Permalink
Fixed a bug causing problems if the users permission attribute is c…
Browse files Browse the repository at this point in the history
…ast to `json`.
  • Loading branch information
warrickbayman committed Feb 27, 2020
1 parent f48c853 commit 2f02caf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.2.2] 27-02-2020
### Changes
- Fixed a bug that was causing problems if the `permissions` attribute is cast to `json`.

## [0.2.1] 27-02-2020
### Additions
- Updated the `Deadbolt::permissions()` to accept role names.
Expand Down
4 changes: 4 additions & 0 deletions src/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ public function has(string $permission): bool
*/
protected function userPermissions(): array
{
if (is_array($this->user->permissions)) {
return $this->user->permissions;
}

return json_decode($this->user->permissions, true) ?: [];
}

Expand Down

0 comments on commit 2f02caf

Please sign in to comment.