{"action":"created","comment":{"url":"https://api.github.com/repos/matul91/meteo-raspi/pulls/comments/178463404","pull_request_review_id":108523596,"id":178463404,"diff_hunk":"@@ -0,0 +1,76 @@\n+<?php\n+\n+namespace App\\Http\\Middleware;\n+use Illuminate\\Http\\Request;\n+use Closure;\n+use App\\Role;\n+use App\\User;\n+\n+class CheckPermissions\n+{\n+    /**\n+     * Handle an incoming request.\n+     *\n+     * @param  \\Illuminate\\Http\\Request  $request\n+     * @param  \\Closure  $next\n+     * @return mixed\n+     */\n+    public function handle($request, Closure $next, $role)\n+    {\n+        $userId = self::getUserIdFromToken($request);\n+        if($userId == 0){\n+            return self::getUnauthorized();\n+        }else{\n+            $userPermissions = User::find($userId)->roles;\n+            $roleArray = explode(\";\", $role);\n+            return self::compareUserPermissions($userPermissions, $roleArray, $next, $request);\n+        }\n+    }\n+\n+    private static function getUserIdFromToken(Request $request){\n+        $result = 0;\n+        if ($request->header('Authorization')){\n+            $res = self::sendTokenToPassport($request);\n+            if($res->getStatusCode() != 401){","path":"app/Http/Middleware/CheckPermissions.php","position":null,"original_position":34,"commit_id":"c63d8413f6d46a75524f3e5ef46cd0a449ed47bb","original_commit_id":"224272871702385b8e25c8dc1b8653e2d7974dad","user":{"login":"FestikCZ","id":26276646,"avatar_url":"https://avatars3.githubusercontent.com/u/26276646?v=4","gravatar_id":"","url":"https://api.github.com/users/FestikCZ","html_url":"https://github.com/FestikCZ","followers_url":"https://api.github.com/users/FestikCZ/followers","following_url":"https://api.github.com/users/FestikCZ/following{/other_user}","gists_url":"https://api.github.com/users/FestikCZ/gists{/gist_id}","starred_url":"https://api.github.com/users/FestikCZ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FestikCZ/subscriptions","organizations_url":"https://api.github.com/users/FestikCZ/orgs","repos_url":"https://api.github.com/users/FestikCZ/repos","events_url":"https://api.github.com/users/FestikCZ/events{/privacy}","received_events_url":"https://api.github.com/users/FestikCZ/received_events","type":"User","site_admin":false},"body":"renamed","created_at":"2018-04-01T16:49:30Z","updated_at":"2018-04-01T16:49:30Z","html_url":"https://github.com/matul91/meteo-raspi/pull/12#discussion_r178463404","pull_request_url":"https://api.github.com/repos/matul91/meteo-raspi/pulls/12","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/matul91/meteo-raspi/pulls/comments/178463404"},"html":{"href":"https://github.com/matul91/meteo-raspi/pull/12#discussion_r178463404"},"pull_request":{"href":"https://api.github.com/repos/matul91/meteo-raspi/pulls/12"}},"in_reply_to_id":177344106},"pull_request":{"url":"https://api.github.com/repos/matul91/meteo-raspi/pulls/12","id":175771368,"html_url":"https://github.com/matul91/meteo-raspi/pull/12","diff_url":"https://github.com/matul91/meteo-raspi/pull/12.diff","patch_url":"https://github.com/matul91/meteo-raspi/pull/12.patch","issue_url":"https://api.github.com/repos/matul91/meteo-raspi/issues/12","number":12,"state":"open","locked":false,"title":"Implement permissions and authorization for api points","user":{"login":"FestikCZ","id":26276646,"avatar_url":"https://avatars3.githubusercontent.com/u/26276646?v=4","gravatar_id":"","url":"https://api.github.com/users/FestikCZ","html_url":"https://github.com/FestikCZ","followers_url":"https://api.github.com/users/FestikCZ/followers","following_url":"https://api.github.com/users/FestikCZ/following{/other_user}","gists_url":"https://api.github.com/users/FestikCZ/gists{/gist_id}","starred_url":"https://api.github.com/users/FestikCZ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FestikCZ/subscriptions","organizations_url":"https://api.github.com/users/FestikCZ/orgs","repos_url":"https://api.github.com/users/FestikCZ/repos","events_url":"https://api.github.com/users/FestikCZ/events{/privacy}","received_events_url":"https://api.github.com/users/FestikCZ/received_events","type":"User","site_admin":false},"body":"test only codeclimate for new feature","created_at":"2018-03-18T20:28:34Z","updated_at":"2018-04-01T16:49:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/matul91/meteo-raspi/pulls/12/commits","review_comments_url":"https://api.github.com/repos/matul91/meteo-raspi/pulls/12/comments","review_comment_url":"https://api.github.com/repos/matul91/meteo-raspi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/matul91/meteo-raspi/issues/12/comments","statuses_url":"https://api.github.com/repos/matul91/meteo-raspi/statuses/c63d8413f6d46a75524f3e5ef46cd0a449ed47bb","head":{"label":"matul91:feature/antl_native_user_authentication_+_role_authorization","ref":"feature/antl_native_user_authentication_+_role_authorization","sha":"c63d8413f6d46a75524f3e5ef46cd0a449ed47bb","user":{"login":"matul91","id":11683229,"avatar_url":"https://avatars0.githubusercontent.com/u/11683229?v=4","gravatar_id":"","url":"https://api.github.com/users/matul91","html_url":"https://github.com/matul91","followers_url":"https://api.github.com/users/matul91/followers","following_url":"https://api.github.com/users/matul91/following{/other_user}","gists_url":"https://api.github.com/users/matul91/gists{/gist_id}","starred_url":"https://api.github.com/users/matul91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matul91/subscriptions","organizations_url":"https://api.github.com/users/matul91/orgs","repos_url":"https://api.github.com/users/matul91/repos","events_url":"https://api.github.com/users/matul91/events{/privacy}","received_events_url":"https://api.github.com/users/matul91/received_events","type":"User","site_admin":false},"repo":{"id":113595685,"name":"meteo-raspi","full_name":"matul91/meteo-raspi","owner":{"login":"matul91","id":11683229,"avatar_url":"https://avatars0.githubusercontent.com/u/11683229?v=4","gravatar_id":"","url":"https://api.github.com/users/matul91","html_url":"https://github.com/matul91","followers_url":"https://api.github.com/users/matul91/followers","following_url":"https://api.github.com/users/matul91/following{/other_user}","gists_url":"https://api.github.com/users/matul91/gists{/gist_id}","starred_url":"https://api.github.com/users/matul91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matul91/subscriptions","organizations_url":"https://api.github.com/users/matul91/orgs","repos_url":"https://api.github.com/users/matul91/repos","events_url":"https://api.github.com/users/matul91/events{/privacy}","received_events_url":"https://api.github.com/users/matul91/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/matul91/meteo-raspi","description":null,"fork":false,"url":"https://api.github.com/repos/matul91/meteo-raspi","forks_url":"https://api.github.com/repos/matul91/meteo-raspi/forks","keys_url":"https://api.github.com/repos/matul91/meteo-raspi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/matul91/meteo-raspi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/matul91/meteo-raspi/teams","hooks_url":"https://api.github.com/repos/matul91/meteo-raspi/hooks","issue_events_url":"https://api.github.com/repos/matul91/meteo-raspi/issues/events{/number}","events_url":"https://api.github.com/repos/matul91/meteo-raspi/events","assignees_url":"https://api.github.com/repos/matul91/meteo-raspi/assignees{/user}","branches_url":"https://api.github.com/repos/matul91/meteo-raspi/branches{/branch}","tags_url":"https://api.github.com/repos/matul91/meteo-raspi/tags","blobs_url":"https://api.github.com/repos/matul91/meteo-raspi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/matul91/meteo-raspi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/matul91/meteo-raspi/git/refs{/sha}","trees_url":"https://api.github.com/repos/matul91/meteo-raspi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/matul91/meteo-raspi/statuses/{sha}","languages_url":"https://api.github.com/repos/matul91/meteo-raspi/languages","stargazers_url":"https://api.github.com/repos/matul91/meteo-raspi/stargazers","contributors_url":"https://api.github.com/repos/matul91/meteo-raspi/contributors","subscribers_url":"https://api.github.com/repos/matul91/meteo-raspi/subscribers","subscription_url":"https://api.github.com/repos/matul91/meteo-raspi/subscription","commits_url":"https://api.github.com/repos/matul91/meteo-raspi/commits{/sha}","git_commits_url":"https://api.github.com/repos/matul91/meteo-raspi/git/commits{/sha}","comments_url":"https://api.github.com/repos/matul91/meteo-raspi/comments{/number}","issue_comment_url":"https://api.github.com/repos/matul91/meteo-raspi/issues/comments{/number}","contents_url":"https://api.github.com/repos/matul91/meteo-raspi/contents/{+path}","compare_url":"https://api.github.com/repos/matul91/meteo-raspi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/matul91/meteo-raspi/merges","archive_url":"https://api.github.com/repos/matul91/meteo-raspi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/matul91/meteo-raspi/downloads","issues_url":"https://api.github.com/repos/matul91/meteo-raspi/issues{/number}","pulls_url":"https://api.github.com/repos/matul91/meteo-raspi/pulls{/number}","milestones_url":"https://api.github.com/repos/matul91/meteo-raspi/milestones{/number}","notifications_url":"https://api.github.com/repos/matul91/meteo-raspi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/matul91/meteo-raspi/labels{/name}","releases_url":"https://api.github.com/repos/matul91/meteo-raspi/releases{/id}","deployments_url":"https://api.github.com/repos/matul91/meteo-raspi/deployments","created_at":"2017-12-08T16:38:58Z","updated_at":"2018-03-07T15:49:33Z","pushed_at":"2018-04-01T16:43:56Z","git_url":"git://github.com/matul91/meteo-raspi.git","ssh_url":"git@github.com:matul91/meteo-raspi.git","clone_url":"https://github.com/matul91/meteo-raspi.git","svn_url":"https://github.com/matul91/meteo-raspi","homepage":null,"size":3804,"stargazers_count":2,"watchers_count":2,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":6,"license":null,"forks":0,"open_issues":6,"watchers":2,"default_branch":"master"}},"base":{"label":"matul91:develop","ref":"develop","sha":"05e01a3df49963590dc61fb8cea13d14c77dd198","user":{"login":"matul91","id":11683229,"avatar_url":"https://avatars0.githubusercontent.com/u/11683229?v=4","gravatar_id":"","url":"https://api.github.com/users/matul91","html_url":"https://github.com/matul91","followers_url":"https://api.github.com/users/matul91/followers","following_url":"https://api.github.com/users/matul91/following{/other_user}","gists_url":"https://api.github.com/users/matul91/gists{/gist_id}","starred_url":"https://api.github.com/users/matul91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matul91/subscriptions","organizations_url":"https://api.github.com/users/matul91/orgs","repos_url":"https://api.github.com/users/matul91/repos","events_url":"https://api.github.com/users/matul91/events{/privacy}","received_events_url":"https://api.github.com/users/matul91/received_events","type":"User","site_admin":false},"repo":{"id":113595685,"name":"meteo-raspi","full_name":"matul91/meteo-raspi","owner":{"login":"matul91","id":11683229,"avatar_url":"https://avatars0.githubusercontent.com/u/11683229?v=4","gravatar_id":"","url":"https://api.github.com/users/matul91","html_url":"https://github.com/matul91","followers_url":"https://api.github.com/users/matul91/followers","following_url":"https://api.github.com/users/matul91/following{/other_user}","gists_url":"https://api.github.com/users/matul91/gists{/gist_id}","starred_url":"https://api.github.com/users/matul91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matul91/subscriptions","organizations_url":"https://api.github.com/users/matul91/orgs","repos_url":"https://api.github.com/users/matul91/repos","events_url":"https://api.github.com/users/matul91/events{/privacy}","received_events_url":"https://api.github.com/users/matul91/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/matul91/meteo-raspi","description":null,"fork":false,"url":"https://api.github.com/repos/matul91/meteo-raspi","forks_url":"https://api.github.com/repos/matul91/meteo-raspi/forks","keys_url":"https://api.github.com/repos/matul91/meteo-raspi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/matul91/meteo-raspi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/matul91/meteo-raspi/teams","hooks_url":"https://api.github.com/repos/matul91/meteo-raspi/hooks","issue_events_url":"https://api.github.com/repos/matul91/meteo-raspi/issues/events{/number}","events_url":"https://api.github.com/repos/matul91/meteo-raspi/events","assignees_url":"https://api.github.com/repos/matul91/meteo-raspi/assignees{/user}","branches_url":"https://api.github.com/repos/matul91/meteo-raspi/branches{/branch}","tags_url":"https://api.github.com/repos/matul91/meteo-raspi/tags","blobs_url":"https://api.github.com/repos/matul91/meteo-raspi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/matul91/meteo-raspi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/matul91/meteo-raspi/git/refs{/sha}","trees_url":"https://api.github.com/repos/matul91/meteo-raspi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/matul91/meteo-raspi/statuses/{sha}","languages_url":"https://api.github.com/repos/matul91/meteo-raspi/languages","stargazers_url":"https://api.github.com/repos/matul91/meteo-raspi/stargazers","contributors_url":"https://api.github.com/repos/matul91/meteo-raspi/contributors","subscribers_url":"https://api.github.com/repos/matul91/meteo-raspi/subscribers","subscription_url":"https://api.github.com/repos/matul91/meteo-raspi/subscription","commits_url":"https://api.github.com/repos/matul91/meteo-raspi/commits{/sha}","git_commits_url":"https://api.github.com/repos/matul91/meteo-raspi/git/commits{/sha}","comments_url":"https://api.github.com/repos/matul91/meteo-raspi/comments{/number}","issue_comment_url":"https://api.github.com/repos/matul91/meteo-raspi/issues/comments{/number}","contents_url":"https://api.github.com/repos/matul91/meteo-raspi/contents/{+path}","compare_url":"https://api.github.com/repos/matul91/meteo-raspi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/matul91/meteo-raspi/merges","archive_url":"https://api.github.com/repos/matul91/meteo-raspi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/matul91/meteo-raspi/downloads","issues_url":"https://api.github.com/repos/matul91/meteo-raspi/issues{/number}","pulls_url":"https://api.github.com/repos/matul91/meteo-raspi/pulls{/number}","milestones_url":"https://api.github.com/repos/matul91/meteo-raspi/milestones{/number}","notifications_url":"https://api.github.com/repos/matul91/meteo-raspi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/matul91/meteo-raspi/labels{/name}","releases_url":"https://api.github.com/repos/matul91/meteo-raspi/releases{/id}","deployments_url":"https://api.github.com/repos/matul91/meteo-raspi/deployments","created_at":"2017-12-08T16:38:58Z","updated_at":"2018-03-07T15:49:33Z","pushed_at":"2018-04-01T16:43:56Z","git_url":"git://github.com/matul91/meteo-raspi.git","ssh_url":"git@github.com:matul91/meteo-raspi.git","clone_url":"https://github.com/matul91/meteo-raspi.git","svn_url":"https://github.com/matul91/meteo-raspi","homepage":null,"size":3804,"stargazers_count":2,"watchers_count":2,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":6,"license":null,"forks":0,"open_issues":6,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/matul91/meteo-raspi/pulls/12"},"html":{"href":"https://github.com/matul91/meteo-raspi/pull/12"},"issue":{"href":"https://api.github.com/repos/matul91/meteo-raspi/issues/12"},"comments":{"href":"https://api.github.com/repos/matul91/meteo-raspi/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/matul91/meteo-raspi/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/matul91/meteo-raspi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/matul91/meteo-raspi/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/matul91/meteo-raspi/statuses/c63d8413f6d46a75524f3e5ef46cd0a449ed47bb"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"FestikCZ"}}