{"action":"closed","issue":{"url":"https://api.github.com/repos/rainlab/user-plugin/issues/108","labels_url":"https://api.github.com/repos/rainlab/user-plugin/issues/108/labels{/name}","comments_url":"https://api.github.com/repos/rainlab/user-plugin/issues/108/comments","events_url":"https://api.github.com/repos/rainlab/user-plugin/issues/108/events","html_url":"https://github.com/rainlab/user-plugin/issues/108","id":104179677,"number":108,"title":"using the method hasRole in backend","user":{"login":"chrisvidal","id":2263496,"avatar_url":"https://avatars.githubusercontent.com/u/2263496?v=3","gravatar_id":"","url":"https://api.github.com/users/chrisvidal","html_url":"https://github.com/chrisvidal","followers_url":"https://api.github.com/users/chrisvidal/followers","following_url":"https://api.github.com/users/chrisvidal/following{/other_user}","gists_url":"https://api.github.com/users/chrisvidal/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisvidal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisvidal/subscriptions","organizations_url":"https://api.github.com/users/chrisvidal/orgs","repos_url":"https://api.github.com/users/chrisvidal/repos","events_url":"https://api.github.com/users/chrisvidal/events{/privacy}","received_events_url":"https://api.github.com/users/chrisvidal/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-09-01T03:53:42Z","updated_at":"2015-09-04T07:27:06Z","closed_at":"2015-09-04T07:27:06Z","body":"Im not sure how to use the hasRole method for the backend.\r\nbasically, i just need to know if the current logged backend use has a role or not, so im trying to use this method like this : \r\nGroup::hasRole('Staff', BackendAuth::getUser() )\r\nBut then an exception is raised on this following line :\r\n$userRoles = json_decode(User::find( $user == null ? $account->user()->id : $user)->groups);\r\nwhich i found a bit weird, why do we search a user if we already passed the user into the argument ?\r\nUser::find($user) does not work and raise the exception apparently\r\nto fix this i changed the code to \r\n$userRoles = json_decode(User::find( $user == null ? $account->user()->id : $user->id)->groups);\r\n\r\n\r\n<bountysource-plugin>\r\n---\r\nWant to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/26350768-using-the-method-hasrole-in-backend?utm_campaign=plugin&utm_content=tracker%2F784048&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F784048&utm_medium=issues&utm_source=github).\r\n</bountysource-plugin>"}}