{"action":"created","comment":{"url":"https://api.github.com/repos/TryGhost/Ghost/pulls/comments/23364980","id":23364980,"diff_hunk":"@@ -150,35 +150,40 @@ users = {\n \n             // Check permissions\n             return canThis(options.context).edit.user(options.id).then(function () {\n-                if (data.users[0].roles && data.users[0].roles[0]) {\n-                    var role = data.users[0].roles[0],\n-                        roleId = parseInt(role.id || role, 10);\n-\n-                    return dataProvider.User.findOne(\n-                        {id: options.context.user, status: 'all'}, {include: ['roles']}\n-                    ).then(function (contextUser) {\n-                        var contextRoleId = contextUser.related('roles').toJSON()[0].id;\n-\n-                        if (roleId !== contextRoleId &&\n-                                parseInt(options.id, 10) === parseInt(options.context.user, 10)) {\n-                            return Promise.reject(new errors.NoPermissionError('You cannot change your own role.'));\n-                        } else if (roleId !== contextRoleId) {\n-                            return dataProvider.User.findOne({role: 'Owner'}).then(function (result) {\n-                                if (parseInt(result.id, 10) !== parseInt(options.id, 10)) {\n-                                    return canThis(options.context).assign.role(role).then(function () {\n-                                        return editOperation();\n-                                    });\n-                                } else {\n-                                    return Promise.reject(new errors.NoPermissionError('There has to be one owner.'));\n+                // if roles aren't in the payload, proceed with the edit\n+                if (!(data.users[0].roles && data.users[0].roles[0])) {\n+                    return editOperation();","path":"core/server/api/users.js","position":26,"original_position":26,"commit_id":"0fc152b2adf6a06d77422867c6e0ca9499b20c80","original_commit_id":"0fc152b2adf6a06d77422867c6e0ca9499b20c80","user":{"login":"ErisDS","id":101513,"avatar_url":"https://avatars.githubusercontent.com/u/101513?v=3","gravatar_id":"","url":"https://api.github.com/users/ErisDS","html_url":"https://github.com/ErisDS","followers_url":"https://api.github.com/users/ErisDS/followers","following_url":"https://api.github.com/users/ErisDS/following{/other_user}","gists_url":"https://api.github.com/users/ErisDS/gists{/gist_id}","starred_url":"https://api.github.com/users/ErisDS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ErisDS/subscriptions","organizations_url":"https://api.github.com/users/ErisDS/orgs","repos_url":"https://api.github.com/users/ErisDS/repos","events_url":"https://api.github.com/users/ErisDS/events{/privacy}","received_events_url":"https://api.github.com/users/ErisDS/received_events","type":"User","site_admin":false},"body":"I'm wondering if this logic is correct?","created_at":"2015-01-22T09:58:21Z","updated_at":"2015-01-22T09:58:21Z","html_url":"https://github.com/TryGhost/Ghost/pull/4831#discussion_r23364980","pull_request_url":"https://api.github.com/repos/TryGhost/Ghost/pulls/4831","_links":{"self":{"href":"https://api.github.com/repos/TryGhost/Ghost/pulls/comments/23364980"},"html":{"href":"https://github.com/TryGhost/Ghost/pull/4831#discussion_r23364980"},"pull_request":{"href":"https://api.github.com/repos/TryGhost/Ghost/pulls/4831"}}},"pull_request":{"url":"https://api.github.com/repos/TryGhost/Ghost/pulls/4831","id":27714532,"html_url":"https://github.com/TryGhost/Ghost/pull/4831","diff_url":"https://github.com/TryGhost/Ghost/pull/4831.diff","patch_url":"https://github.com/TryGhost/Ghost/pull/4831.patch","issue_url":"https://api.github.com/repos/TryGhost/Ghost/issues/4831","number":4831,"state":"open","locked":false,"title":"Fix up users API so admin role can edit owner","user":{"login":"jaswilli","id":214142,"avatar_url":"https://avatars.githubusercontent.com/u/214142?v=3","gravatar_id":"","url":"https://api.github.com/users/jaswilli","html_url":"https://github.com/jaswilli","followers_url":"https://api.github.com/users/jaswilli/followers","following_url":"https://api.github.com/users/jaswilli/following{/other_user}","gists_url":"https://api.github.com/users/jaswilli/gists{/gist_id}","starred_url":"https://api.github.com/users/jaswilli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaswilli/subscriptions","organizations_url":"https://api.github.com/users/jaswilli/orgs","repos_url":"https://api.github.com/users/jaswilli/repos","events_url":"https://api.github.com/users/jaswilli/events{/privacy}","received_events_url":"https://api.github.com/users/jaswilli/received_events","type":"User","site_admin":false},"body":"No Issue.\r\n- Make sure that a user with the Admin role can edit the Owner.\r\n- Add test for behavior.\r\n\r\nDepends on #4830.","created_at":"2015-01-20T21:37:06Z","updated_at":"2015-01-22T09:58:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9f6a30a075b08962f6b5bcb6771fed989d63b18b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/TryGhost/Ghost/pulls/4831/commits","review_comments_url":"https://api.github.com/repos/TryGhost/Ghost/pulls/4831/comments","review_comment_url":"https://api.github.com/repos/TryGhost/Ghost/pulls/comments/{number}","comments_url":"https://api.github.com/repos/TryGhost/Ghost/issues/4831/comments","statuses_url":"https://api.github.com/repos/TryGhost/Ghost/statuses/0fc152b2adf6a06d77422867c6e0ca9499b20c80","head":{"label":"jaswilli:edit-user","ref":"edit-user","sha":"0fc152b2adf6a06d77422867c6e0ca9499b20c80","user":{"login":"jaswilli","id":214142,"avatar_url":"https://avatars.githubusercontent.com/u/214142?v=3","gravatar_id":"","url":"https://api.github.com/users/jaswilli","html_url":"https://github.com/jaswilli","followers_url":"https://api.github.com/users/jaswilli/followers","following_url":"https://api.github.com/users/jaswilli/following{/other_user}","gists_url":"https://api.github.com/users/jaswilli/gists{/gist_id}","starred_url":"https://api.github.com/users/jaswilli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaswilli/subscriptions","organizations_url":"https://api.github.com/users/jaswilli/orgs","repos_url":"https://api.github.com/users/jaswilli/repos","events_url":"https://api.github.com/users/jaswilli/events{/privacy}","received_events_url":"https://api.github.com/users/jaswilli/received_events","type":"User","site_admin":false},"repo":{"id":17843863,"name":"Ghost","full_name":"jaswilli/Ghost","owner":{"login":"jaswilli","id":214142,"avatar_url":"https://avatars.githubusercontent.com/u/214142?v=3","gravatar_id":"","url":"https://api.github.com/users/jaswilli","html_url":"https://github.com/jaswilli","followers_url":"https://api.github.com/users/jaswilli/followers","following_url":"https://api.github.com/users/jaswilli/following{/other_user}","gists_url":"https://api.github.com/users/jaswilli/gists{/gist_id}","starred_url":"https://api.github.com/users/jaswilli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaswilli/subscriptions","organizations_url":"https://api.github.com/users/jaswilli/orgs","repos_url":"https://api.github.com/users/jaswilli/repos","events_url":"https://api.github.com/users/jaswilli/events{/privacy}","received_events_url":"https://api.github.com/users/jaswilli/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jaswilli/Ghost","description":"Just a blogging platform","fork":true,"url":"https://api.github.com/repos/jaswilli/Ghost","forks_url":"https://api.github.com/repos/jaswilli/Ghost/forks","keys_url":"https://api.github.com/repos/jaswilli/Ghost/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jaswilli/Ghost/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jaswilli/Ghost/teams","hooks_url":"https://api.github.com/repos/jaswilli/Ghost/hooks","issue_events_url":"https://api.github.com/repos/jaswilli/Ghost/issues/events{/number}","events_url":"https://api.github.com/repos/jaswilli/Ghost/events","assignees_url":"https://api.github.com/repos/jaswilli/Ghost/assignees{/user}","branches_url":"https://api.github.com/repos/jaswilli/Ghost/branches{/branch}","tags_url":"https://api.github.com/repos/jaswilli/Ghost/tags","blobs_url":"https://api.github.com/repos/jaswilli/Ghost/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jaswilli/Ghost/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jaswilli/Ghost/git/refs{/sha}","trees_url":"https://api.github.com/repos/jaswilli/Ghost/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jaswilli/Ghost/statuses/{sha}","languages_url":"https://api.github.com/repos/jaswilli/Ghost/languages","stargazers_url":"https://api.github.com/repos/jaswilli/Ghost/stargazers","contributors_url":"https://api.github.com/repos/jaswilli/Ghost/contributors","subscribers_url":"https://api.github.com/repos/jaswilli/Ghost/subscribers","subscription_url":"https://api.github.com/repos/jaswilli/Ghost/subscription","commits_url":"https://api.github.com/repos/jaswilli/Ghost/commits{/sha}","git_commits_url":"https://api.github.com/repos/jaswilli/Ghost/git/commits{/sha}","comments_url":"https://api.github.com/repos/jaswilli/Ghost/comments{/number}","issue_comment_url":"https://api.github.com/repos/jaswilli/Ghost/issues/comments/{number}","contents_url":"https://api.github.com/repos/jaswilli/Ghost/contents/{+path}","compare_url":"https://api.github.com/repos/jaswilli/Ghost/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jaswilli/Ghost/merges","archive_url":"https://api.github.com/repos/jaswilli/Ghost/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jaswilli/Ghost/downloads","issues_url":"https://api.github.com/repos/jaswilli/Ghost/issues{/number}","pulls_url":"https://api.github.com/repos/jaswilli/Ghost/pulls{/number}","milestones_url":"https://api.github.com/repos/jaswilli/Ghost/milestones{/number}","notifications_url":"https://api.github.com/repos/jaswilli/Ghost/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jaswilli/Ghost/labels{/name}","releases_url":"https://api.github.com/repos/jaswilli/Ghost/releases{/id}","created_at":"2014-03-17T21:23:46Z","updated_at":"2014-12-18T16:47:22Z","pushed_at":"2015-01-21T18:10:34Z","git_url":"git://github.com/jaswilli/Ghost.git","ssh_url":"git@github.com:jaswilli/Ghost.git","clone_url":"https://github.com/jaswilli/Ghost.git","svn_url":"https://github.com/jaswilli/Ghost","homepage":"https://ghost.org","size":16352,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"TryGhost:master","ref":"master","sha":"e26d1a92576f9e6f9c376878e623a0a3a9313793","user":{"login":"TryGhost","id":2178663,"avatar_url":"https://avatars.githubusercontent.com/u/2178663?v=3","gravatar_id":"","url":"https://api.github.com/users/TryGhost","html_url":"https://github.com/TryGhost","followers_url":"https://api.github.com/users/TryGhost/followers","following_url":"https://api.github.com/users/TryGhost/following{/other_user}","gists_url":"https://api.github.com/users/TryGhost/gists{/gist_id}","starred_url":"https://api.github.com/users/TryGhost/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TryGhost/subscriptions","organizations_url":"https://api.github.com/users/TryGhost/orgs","repos_url":"https://api.github.com/users/TryGhost/repos","events_url":"https://api.github.com/users/TryGhost/events{/privacy}","received_events_url":"https://api.github.com/users/TryGhost/received_events","type":"Organization","site_admin":false},"repo":{"id":9852918,"name":"Ghost","full_name":"TryGhost/Ghost","owner":{"login":"TryGhost","id":2178663,"avatar_url":"https://avatars.githubusercontent.com/u/2178663?v=3","gravatar_id":"","url":"https://api.github.com/users/TryGhost","html_url":"https://github.com/TryGhost","followers_url":"https://api.github.com/users/TryGhost/followers","following_url":"https://api.github.com/users/TryGhost/following{/other_user}","gists_url":"https://api.github.com/users/TryGhost/gists{/gist_id}","starred_url":"https://api.github.com/users/TryGhost/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TryGhost/subscriptions","organizations_url":"https://api.github.com/users/TryGhost/orgs","repos_url":"https://api.github.com/users/TryGhost/repos","events_url":"https://api.github.com/users/TryGhost/events{/privacy}","received_events_url":"https://api.github.com/users/TryGhost/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/TryGhost/Ghost","description":"Just a blogging platform","fork":false,"url":"https://api.github.com/repos/TryGhost/Ghost","forks_url":"https://api.github.com/repos/TryGhost/Ghost/forks","keys_url":"https://api.github.com/repos/TryGhost/Ghost/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TryGhost/Ghost/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TryGhost/Ghost/teams","hooks_url":"https://api.github.com/repos/TryGhost/Ghost/hooks","issue_events_url":"https://api.github.com/repos/TryGhost/Ghost/issues/events{/number}","events_url":"https://api.github.com/repos/TryGhost/Ghost/events","assignees_url":"https://api.github.com/repos/TryGhost/Ghost/assignees{/user}","branches_url":"https://api.github.com/repos/TryGhost/Ghost/branches{/branch}","tags_url":"https://api.github.com/repos/TryGhost/Ghost/tags","blobs_url":"https://api.github.com/repos/TryGhost/Ghost/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TryGhost/Ghost/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TryGhost/Ghost/git/refs{/sha}","trees_url":"https://api.github.com/repos/TryGhost/Ghost/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TryGhost/Ghost/statuses/{sha}","languages_url":"https://api.github.com/repos/TryGhost/Ghost/languages","stargazers_url":"https://api.github.com/repos/TryGhost/Ghost/stargazers","contributors_url":"https://api.github.com/repos/TryGhost/Ghost/contributors","subscribers_url":"https://api.github.com/repos/TryGhost/Ghost/subscribers","subscription_url":"https://api.github.com/repos/TryGhost/Ghost/subscription","commits_url":"https://api.github.com/repos/TryGhost/Ghost/commits{/sha}","git_commits_url":"https://api.github.com/repos/TryGhost/Ghost/git/commits{/sha}","comments_url":"https://api.github.com/repos/TryGhost/Ghost/comments{/number}","issue_comment_url":"https://api.github.com/repos/TryGhost/Ghost/issues/comments/{number}","contents_url":"https://api.github.com/repos/TryGhost/Ghost/contents/{+path}","compare_url":"https://api.github.com/repos/TryGhost/Ghost/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TryGhost/Ghost/merges","archive_url":"https://api.github.com/repos/TryGhost/Ghost/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TryGhost/Ghost/downloads","issues_url":"https://api.github.com/repos/TryGhost/Ghost/issues{/number}","pulls_url":"https://api.github.com/repos/TryGhost/Ghost/pulls{/number}","milestones_url":"https://api.github.com/repos/TryGhost/Ghost/milestones{/number}","notifications_url":"https://api.github.com/repos/TryGhost/Ghost/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TryGhost/Ghost/labels{/name}","releases_url":"https://api.github.com/repos/TryGhost/Ghost/releases{/id}","created_at":"2013-05-04T11:09:13Z","updated_at":"2015-01-22T09:48:09Z","pushed_at":"2015-01-21T11:01:44Z","git_url":"git://github.com/TryGhost/Ghost.git","ssh_url":"git@github.com:TryGhost/Ghost.git","clone_url":"https://github.com/TryGhost/Ghost.git","svn_url":"https://github.com/TryGhost/Ghost","homepage":"https://ghost.org","size":55695,"stargazers_count":13769,"watchers_count":13769,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":3120,"mirror_url":null,"open_issues_count":222,"forks":3120,"open_issues":222,"watchers":13769,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/TryGhost/Ghost/pulls/4831"},"html":{"href":"https://github.com/TryGhost/Ghost/pull/4831"},"issue":{"href":"https://api.github.com/repos/TryGhost/Ghost/issues/4831"},"comments":{"href":"https://api.github.com/repos/TryGhost/Ghost/issues/4831/comments"},"review_comments":{"href":"https://api.github.com/repos/TryGhost/Ghost/pulls/4831/comments"},"review_comment":{"href":"https://api.github.com/repos/TryGhost/Ghost/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/TryGhost/Ghost/pulls/4831/commits"},"statuses":{"href":"https://api.github.com/repos/TryGhost/Ghost/statuses/0fc152b2adf6a06d77422867c6e0ca9499b20c80"}}}}