{"action":"created","issue":{"url":"https://api.github.com/repos/cartalyst/sentinel/issues/154","labels_url":"https://api.github.com/repos/cartalyst/sentinel/issues/154/labels{/name}","comments_url":"https://api.github.com/repos/cartalyst/sentinel/issues/154/comments","events_url":"https://api.github.com/repos/cartalyst/sentinel/issues/154/events","html_url":"https://github.com/cartalyst/sentinel/issues/154","id":113975632,"number":154,"title":"How to set the Middleware when route in two roles?","user":{"login":"denise92","id":5656509,"avatar_url":"https://avatars.githubusercontent.com/u/5656509?v=3","gravatar_id":"","url":"https://api.github.com/users/denise92","html_url":"https://github.com/denise92","followers_url":"https://api.github.com/users/denise92/followers","following_url":"https://api.github.com/users/denise92/following{/other_user}","gists_url":"https://api.github.com/users/denise92/gists{/gist_id}","starred_url":"https://api.github.com/users/denise92/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/denise92/subscriptions","organizations_url":"https://api.github.com/users/denise92/orgs","repos_url":"https://api.github.com/users/denise92/repos","events_url":"https://api.github.com/users/denise92/events{/privacy}","received_events_url":"https://api.github.com/users/denise92/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-29T04:00:46Z","updated_at":"2015-10-29T04:22:52Z","closed_at":"2015-10-29T04:22:52Z","body":"I have two roles that they all have the same permissions and set it true with user_profile.\r\n\r\n```json\r\n{\r\n    id: \"1\",\r\n    slug: \"admin\",\r\n    name: \"Admin\",\r\n    permissions: {\r\n        user_create: true\r\n        user_profile: true\r\n    },\r\n    created_at: \"2014-02-17 02:43:01\",\r\n    updated_at: \"2014-02-17 02:43:37\"\r\n}\r\n{\r\n    id: \"2\",\r\n    slug: \"member\",\r\n    name: \"Member\",\r\n    permissions: {\r\n        user_create: false\r\n        user_profile: true\r\n    },\r\n    created_at: \"2014-02-17 02:43:01\",\r\n    updated_at: \"2014-02-17 02:43:37\"\r\n}\r\n```\r\n\r\nHow to set the Middleware and Route easier?\r\nWhen I login whit Member, than I always get no access message to return...\r\n\r\nIn routes.php:\r\n\r\n```php\r\n// Admin & Member can see this pahe.\r\nRoute::group(['middleware' => ['admin','member']], function (){\r\n    Route::get('user_profile/{id}', ['uses' => 'UserController@index']); \r\n});\r\n```\r\n\r\nIn Middleware/SentinelAdminAccess.php\r\n\r\n```php\r\n<?php\r\n\r\nnamespace App\\Http\\Middleware;\r\n\r\nuse Closure;\r\nuse Sentinel;\r\n\r\nclass SentinelAdminAccess\r\n{\r\n    /**\r\n     * Handle an incoming request.\r\n     *\r\n     * @param  \\Illuminate\\Http\\Request $request\r\n     * @param  \\Closure $next\r\n     * @return mixed\r\n     */\r\n    public function handle($request, Closure $next)\r\n    {\r\n        // Now check to see if the current user has the 'member' permission\r\n        if (!Sentinel::getUser()->inRole('Admin')) {\r\n            if ($request->ajax()) {\r\n                return response('Unauthorized.', 401);\r\n            } else {\r\n                return back()->withInput()->withErrors(trans('auth.user.noaccess'));\r\n            }\r\n        }\r\n        // All clear - we are good to move forward\r\n        return $next($request);\r\n    }\r\n}\r\n```\r\n\r\nIn Middleware/SentinelMemberAccess.php\r\n\r\n```php\r\n<?php\r\n\r\nnamespace App\\Http\\Middleware;\r\n\r\nuse Closure;\r\nuse Sentinel;\r\nuse Session;\r\n\r\nclass SentinelMemberAccess\r\n{\r\n    /**\r\n     * Handle an incoming request.\r\n     *\r\n     * @param  \\Illuminate\\Http\\Request $request\r\n     * @param  \\Closure $next\r\n     * @return mixed\r\n     */\r\n    public function handle($request, Closure $next)\r\n    {\r\n        // Now check to see if the current user has the 'admin' permission\r\n        if (!Sentinel::getUser()->inRole('Member')) {\r\n            if ($request->ajax()) {\r\n                return response('Unauthorized.', 401);\r\n            } else {\r\n                Session::flash('error', trans('auth.user.noaccess'));\r\n                return back()->withInput()->withErrors(trans('auth.user.noaccess'));\r\n            }\r\n        }\r\n        // All clear - we are good to move forward\r\n        return $next($request);\r\n    }\r\n}\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/cartalyst/sentinel/issues/comments/152072573","html_url":"https://github.com/cartalyst/sentinel/issues/154#issuecomment-152072573","issue_url":"https://api.github.com/repos/cartalyst/sentinel/issues/154","id":152072573,"user":{"login":"brunogaspar","id":2285372,"avatar_url":"https://avatars.githubusercontent.com/u/2285372?v=3","gravatar_id":"","url":"https://api.github.com/users/brunogaspar","html_url":"https://github.com/brunogaspar","followers_url":"https://api.github.com/users/brunogaspar/followers","following_url":"https://api.github.com/users/brunogaspar/following{/other_user}","gists_url":"https://api.github.com/users/brunogaspar/gists{/gist_id}","starred_url":"https://api.github.com/users/brunogaspar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brunogaspar/subscriptions","organizations_url":"https://api.github.com/users/brunogaspar/orgs","repos_url":"https://api.github.com/users/brunogaspar/repos","events_url":"https://api.github.com/users/brunogaspar/events{/privacy}","received_events_url":"https://api.github.com/users/brunogaspar/received_events","type":"User","site_admin":false},"created_at":"2015-10-29T04:22:52Z","updated_at":"2015-10-29T04:22:52Z","body":"Just remove the `admin` from your middleware array i guess.\r\n\r\nYou should ask this on the Laravel forums."}}