{"action":"created","comment":{"url":"https://api.github.com/repos/gae-init/gae-init/pulls/comments/51418620","id":51418620,"diff_hunk":"@@ -28,9 +28,10 @@ def post(self):\n     if not username or not password:\n       return flask.abort(400)\n \n-    if username.find('@') > 0:\n+    user_db = None\n+    if '@' in username:\n       user_db = model.User.get_by('email', username.lower())\n-    else:\n+    if not user_db:\n       user_db = model.User.get_by('username', username.lower())","path":"main/api/v1/auth.py","position":10,"original_position":10,"commit_id":"f05bf9eeac09a7eb1bf440d384d01b6aace33d85","original_commit_id":"f05bf9eeac09a7eb1bf440d384d01b6aace33d85","user":{"login":"lipis","id":125676,"avatar_url":"https://avatars.githubusercontent.com/u/125676?v=3","gravatar_id":"","url":"https://api.github.com/users/lipis","html_url":"https://github.com/lipis","followers_url":"https://api.github.com/users/lipis/followers","following_url":"https://api.github.com/users/lipis/following{/other_user}","gists_url":"https://api.github.com/users/lipis/gists{/gist_id}","starred_url":"https://api.github.com/users/lipis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lipis/subscriptions","organizations_url":"https://api.github.com/users/lipis/orgs","repos_url":"https://api.github.com/users/lipis/repos","events_url":"https://api.github.com/users/lipis/events{/privacy}","received_events_url":"https://api.github.com/users/lipis/received_events","type":"User","site_admin":false},"body":"or if won't fit..\r\n\r\n```\r\nuser_db = model.User.get_by(\r\n  ['username', 'email']['@' in handler], handler.lower(),\r\n)\r\n```","created_at":"2016-02-01T13:42:28Z","updated_at":"2016-02-01T13:42:28Z","html_url":"https://github.com/gae-init/gae-init/pull/470#discussion_r51418620","pull_request_url":"https://api.github.com/repos/gae-init/gae-init/pulls/470","_links":{"self":{"href":"https://api.github.com/repos/gae-init/gae-init/pulls/comments/51418620"},"html":{"href":"https://github.com/gae-init/gae-init/pull/470#discussion_r51418620"},"pull_request":{"href":"https://api.github.com/repos/gae-init/gae-init/pulls/470"}}},"pull_request":{"url":"https://api.github.com/repos/gae-init/gae-init/pulls/470","id":57780719,"html_url":"https://github.com/gae-init/gae-init/pull/470","diff_url":"https://github.com/gae-init/gae-init/pull/470.diff","patch_url":"https://github.com/gae-init/gae-init/pull/470.patch","issue_url":"https://api.github.com/repos/gae-init/gae-init/issues/470","number":470,"state":"open","locked":false,"title":"Improved api.auth.signing username/email handling","user":{"login":"mdxs","id":1143642,"avatar_url":"https://avatars.githubusercontent.com/u/1143642?v=3","gravatar_id":"","url":"https://api.github.com/users/mdxs","html_url":"https://github.com/mdxs","followers_url":"https://api.github.com/users/mdxs/followers","following_url":"https://api.github.com/users/mdxs/following{/other_user}","gists_url":"https://api.github.com/users/mdxs/gists{/gist_id}","starred_url":"https://api.github.com/users/mdxs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdxs/subscriptions","organizations_url":"https://api.github.com/users/mdxs/orgs","repos_url":"https://api.github.com/users/mdxs/repos","events_url":"https://api.github.com/users/mdxs/events{/privacy}","received_events_url":"https://api.github.com/users/mdxs/received_events","type":"User","site_admin":false},"body":"Changed the `username.find('@') > 0` to a `'@' in username` construct, which according to http://stackoverflow.com/a/18437825 is more readable (and less important: faster).\r\n\r\nAlso, it looked to me that if somehow I have a username with an '@' inside, and provide that as credentials to the `api.auth.signing` end-point, the routine would not find me... thinking that because of the `@` it must be an email address; which if different from my username w/`@` wouldn't be found; and then assuming that there is nothing more to check. I fixed this by allowing the routine to check it as an email, and if it finds it... okay; but if it didn't find a match, it will still check it as a username (and find me).\r\n\r\nA further improvement could of course be to actually consider the given arguments and handle these directly, rather then funnelling both username and email through this lookup/check.","created_at":"2016-01-31T21:24:27Z","updated_at":"2016-02-01T13:42:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"951c09d2c06f4e08e88f265ca6d320b506acf03d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/gae-init/gae-init/pulls/470/commits","review_comments_url":"https://api.github.com/repos/gae-init/gae-init/pulls/470/comments","review_comment_url":"https://api.github.com/repos/gae-init/gae-init/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gae-init/gae-init/issues/470/comments","statuses_url":"https://api.github.com/repos/gae-init/gae-init/statuses/f05bf9eeac09a7eb1bf440d384d01b6aace33d85","head":{"label":"mdxs:fix_api_auth_signin","ref":"fix_api_auth_signin","sha":"f05bf9eeac09a7eb1bf440d384d01b6aace33d85","user":{"login":"mdxs","id":1143642,"avatar_url":"https://avatars.githubusercontent.com/u/1143642?v=3","gravatar_id":"","url":"https://api.github.com/users/mdxs","html_url":"https://github.com/mdxs","followers_url":"https://api.github.com/users/mdxs/followers","following_url":"https://api.github.com/users/mdxs/following{/other_user}","gists_url":"https://api.github.com/users/mdxs/gists{/gist_id}","starred_url":"https://api.github.com/users/mdxs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdxs/subscriptions","organizations_url":"https://api.github.com/users/mdxs/orgs","repos_url":"https://api.github.com/users/mdxs/repos","events_url":"https://api.github.com/users/mdxs/events{/privacy}","received_events_url":"https://api.github.com/users/mdxs/received_events","type":"User","site_admin":false},"repo":{"id":42685493,"name":"gae-init","full_name":"mdxs/gae-init","owner":{"login":"mdxs","id":1143642,"avatar_url":"https://avatars.githubusercontent.com/u/1143642?v=3","gravatar_id":"","url":"https://api.github.com/users/mdxs","html_url":"https://github.com/mdxs","followers_url":"https://api.github.com/users/mdxs/followers","following_url":"https://api.github.com/users/mdxs/following{/other_user}","gists_url":"https://api.github.com/users/mdxs/gists{/gist_id}","starred_url":"https://api.github.com/users/mdxs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdxs/subscriptions","organizations_url":"https://api.github.com/users/mdxs/orgs","repos_url":"https://api.github.com/users/mdxs/repos","events_url":"https://api.github.com/users/mdxs/events{/privacy}","received_events_url":"https://api.github.com/users/mdxs/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mdxs/gae-init","description":"Google App Engine based on Flask, RESTful, Bootstrap and tons of other cool features","fork":true,"url":"https://api.github.com/repos/mdxs/gae-init","forks_url":"https://api.github.com/repos/mdxs/gae-init/forks","keys_url":"https://api.github.com/repos/mdxs/gae-init/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mdxs/gae-init/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mdxs/gae-init/teams","hooks_url":"https://api.github.com/repos/mdxs/gae-init/hooks","issue_events_url":"https://api.github.com/repos/mdxs/gae-init/issues/events{/number}","events_url":"https://api.github.com/repos/mdxs/gae-init/events","assignees_url":"https://api.github.com/repos/mdxs/gae-init/assignees{/user}","branches_url":"https://api.github.com/repos/mdxs/gae-init/branches{/branch}","tags_url":"https://api.github.com/repos/mdxs/gae-init/tags","blobs_url":"https://api.github.com/repos/mdxs/gae-init/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mdxs/gae-init/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mdxs/gae-init/git/refs{/sha}","trees_url":"https://api.github.com/repos/mdxs/gae-init/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mdxs/gae-init/statuses/{sha}","languages_url":"https://api.github.com/repos/mdxs/gae-init/languages","stargazers_url":"https://api.github.com/repos/mdxs/gae-init/stargazers","contributors_url":"https://api.github.com/repos/mdxs/gae-init/contributors","subscribers_url":"https://api.github.com/repos/mdxs/gae-init/subscribers","subscription_url":"https://api.github.com/repos/mdxs/gae-init/subscription","commits_url":"https://api.github.com/repos/mdxs/gae-init/commits{/sha}","git_commits_url":"https://api.github.com/repos/mdxs/gae-init/git/commits{/sha}","comments_url":"https://api.github.com/repos/mdxs/gae-init/comments{/number}","issue_comment_url":"https://api.github.com/repos/mdxs/gae-init/issues/comments{/number}","contents_url":"https://api.github.com/repos/mdxs/gae-init/contents/{+path}","compare_url":"https://api.github.com/repos/mdxs/gae-init/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mdxs/gae-init/merges","archive_url":"https://api.github.com/repos/mdxs/gae-init/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mdxs/gae-init/downloads","issues_url":"https://api.github.com/repos/mdxs/gae-init/issues{/number}","pulls_url":"https://api.github.com/repos/mdxs/gae-init/pulls{/number}","milestones_url":"https://api.github.com/repos/mdxs/gae-init/milestones{/number}","notifications_url":"https://api.github.com/repos/mdxs/gae-init/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mdxs/gae-init/labels{/name}","releases_url":"https://api.github.com/repos/mdxs/gae-init/releases{/id}","deployments_url":"https://api.github.com/repos/mdxs/gae-init/deployments","created_at":"2015-09-17T22:32:33Z","updated_at":"2016-01-31T15:49:46Z","pushed_at":"2016-01-31T21:14:57Z","git_url":"git://github.com/mdxs/gae-init.git","ssh_url":"git@github.com:mdxs/gae-init.git","clone_url":"https://github.com/mdxs/gae-init.git","svn_url":"https://github.com/mdxs/gae-init","homepage":"https://gae-init.appspot.com","size":5166,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"gae-init:master","ref":"master","sha":"a9f056dbf581f59fd4ecd332d87e53009245c95a","user":{"login":"gae-init","id":5231014,"avatar_url":"https://avatars.githubusercontent.com/u/5231014?v=3","gravatar_id":"","url":"https://api.github.com/users/gae-init","html_url":"https://github.com/gae-init","followers_url":"https://api.github.com/users/gae-init/followers","following_url":"https://api.github.com/users/gae-init/following{/other_user}","gists_url":"https://api.github.com/users/gae-init/gists{/gist_id}","starred_url":"https://api.github.com/users/gae-init/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gae-init/subscriptions","organizations_url":"https://api.github.com/users/gae-init/orgs","repos_url":"https://api.github.com/users/gae-init/repos","events_url":"https://api.github.com/users/gae-init/events{/privacy}","received_events_url":"https://api.github.com/users/gae-init/received_events","type":"Organization","site_admin":false},"repo":{"id":8519889,"name":"gae-init","full_name":"gae-init/gae-init","owner":{"login":"gae-init","id":5231014,"avatar_url":"https://avatars.githubusercontent.com/u/5231014?v=3","gravatar_id":"","url":"https://api.github.com/users/gae-init","html_url":"https://github.com/gae-init","followers_url":"https://api.github.com/users/gae-init/followers","following_url":"https://api.github.com/users/gae-init/following{/other_user}","gists_url":"https://api.github.com/users/gae-init/gists{/gist_id}","starred_url":"https://api.github.com/users/gae-init/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gae-init/subscriptions","organizations_url":"https://api.github.com/users/gae-init/orgs","repos_url":"https://api.github.com/users/gae-init/repos","events_url":"https://api.github.com/users/gae-init/events{/privacy}","received_events_url":"https://api.github.com/users/gae-init/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gae-init/gae-init","description":"Google App Engine based on Flask, RESTful, Bootstrap and tons of other cool features","fork":false,"url":"https://api.github.com/repos/gae-init/gae-init","forks_url":"https://api.github.com/repos/gae-init/gae-init/forks","keys_url":"https://api.github.com/repos/gae-init/gae-init/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gae-init/gae-init/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gae-init/gae-init/teams","hooks_url":"https://api.github.com/repos/gae-init/gae-init/hooks","issue_events_url":"https://api.github.com/repos/gae-init/gae-init/issues/events{/number}","events_url":"https://api.github.com/repos/gae-init/gae-init/events","assignees_url":"https://api.github.com/repos/gae-init/gae-init/assignees{/user}","branches_url":"https://api.github.com/repos/gae-init/gae-init/branches{/branch}","tags_url":"https://api.github.com/repos/gae-init/gae-init/tags","blobs_url":"https://api.github.com/repos/gae-init/gae-init/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gae-init/gae-init/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gae-init/gae-init/git/refs{/sha}","trees_url":"https://api.github.com/repos/gae-init/gae-init/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gae-init/gae-init/statuses/{sha}","languages_url":"https://api.github.com/repos/gae-init/gae-init/languages","stargazers_url":"https://api.github.com/repos/gae-init/gae-init/stargazers","contributors_url":"https://api.github.com/repos/gae-init/gae-init/contributors","subscribers_url":"https://api.github.com/repos/gae-init/gae-init/subscribers","subscription_url":"https://api.github.com/repos/gae-init/gae-init/subscription","commits_url":"https://api.github.com/repos/gae-init/gae-init/commits{/sha}","git_commits_url":"https://api.github.com/repos/gae-init/gae-init/git/commits{/sha}","comments_url":"https://api.github.com/repos/gae-init/gae-init/comments{/number}","issue_comment_url":"https://api.github.com/repos/gae-init/gae-init/issues/comments{/number}","contents_url":"https://api.github.com/repos/gae-init/gae-init/contents/{+path}","compare_url":"https://api.github.com/repos/gae-init/gae-init/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gae-init/gae-init/merges","archive_url":"https://api.github.com/repos/gae-init/gae-init/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gae-init/gae-init/downloads","issues_url":"https://api.github.com/repos/gae-init/gae-init/issues{/number}","pulls_url":"https://api.github.com/repos/gae-init/gae-init/pulls{/number}","milestones_url":"https://api.github.com/repos/gae-init/gae-init/milestones{/number}","notifications_url":"https://api.github.com/repos/gae-init/gae-init/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gae-init/gae-init/labels{/name}","releases_url":"https://api.github.com/repos/gae-init/gae-init/releases{/id}","deployments_url":"https://api.github.com/repos/gae-init/gae-init/deployments","created_at":"2013-03-02T11:58:49Z","updated_at":"2016-01-28T20:32:35Z","pushed_at":"2016-01-31T21:24:27Z","git_url":"git://github.com/gae-init/gae-init.git","ssh_url":"git@github.com:gae-init/gae-init.git","clone_url":"https://github.com/gae-init/gae-init.git","svn_url":"https://github.com/gae-init/gae-init","homepage":"https://gae-init.appspot.com","size":6173,"stargazers_count":235,"watchers_count":235,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":83,"mirror_url":null,"open_issues_count":10,"forks":83,"open_issues":10,"watchers":235,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gae-init/gae-init/pulls/470"},"html":{"href":"https://github.com/gae-init/gae-init/pull/470"},"issue":{"href":"https://api.github.com/repos/gae-init/gae-init/issues/470"},"comments":{"href":"https://api.github.com/repos/gae-init/gae-init/issues/470/comments"},"review_comments":{"href":"https://api.github.com/repos/gae-init/gae-init/pulls/470/comments"},"review_comment":{"href":"https://api.github.com/repos/gae-init/gae-init/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gae-init/gae-init/pulls/470/commits"},"statuses":{"href":"https://api.github.com/repos/gae-init/gae-init/statuses/f05bf9eeac09a7eb1bf440d384d01b6aace33d85"}}}}