X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/56be10f1cd65386063ae3d10da82a81b0aefbf15..refs/pull/2227/head:/app/Auth/User.php diff --git a/app/Auth/User.php b/app/Auth/User.php index 28fb9c7fc..f65ef5316 100644 --- a/app/Auth/User.php +++ b/app/Auth/User.php @@ -47,7 +47,10 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon * The attributes excluded from the model's JSON form. * @var array */ - protected $hidden = ['password', 'remember_token', 'system_name', 'email_confirmed', 'external_auth_id', 'email']; + protected $hidden = [ + 'password', 'remember_token', 'system_name', 'email_confirmed', 'external_auth_id', 'email', + 'created_at', 'updated_at', 'image_id', + ]; /** * This holds the user's permissions when loaded. @@ -98,12 +101,10 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon /** * Check if the user has a role. - * @param $role - * @return mixed */ - public function hasRole($role) + public function hasRole($roleId): bool { - return $this->roles->pluck('name')->contains($role); + return $this->roles->pluck('id')->contains($roleId); } /** @@ -160,7 +161,6 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon /** * Attach a role to this user. - * @param Role $role */ public function attachRole(Role $role) {