From 2f02caf96d8e531e1e6fa10cc606017ad181ac36 Mon Sep 17 00:00:00 2001 From: warrickbayman Date: Thu, 27 Feb 2020 09:37:18 +0200 Subject: [PATCH] Fixed a bug causing problems if the users `permission` attribute is cast to `json`. --- CHANGELOG.md | 4 ++++ src/User.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index deb8d1f..0e48075 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/src/User.php b/src/User.php index be80e19..c69eed8 100644 --- a/src/User.php +++ b/src/User.php @@ -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) ?: []; }