{"action":"created","comment":{"url":"https://api.github.com/repos/tidepool-org/shoreline/pulls/comments/36484908","id":36484908,"diff_hunk":"@@ -125,26 +125,43 @@ func (a *Api) GetStatus(res http.ResponseWriter, req *http.Request) {\n // status: 500 STATUS_ERR_GENERATING_TOKEN\n func (a *Api) CreateUser(res http.ResponseWriter, req *http.Request) {\n \n-\tif usrDetails := getUserDetail(req); usrDetails != nil {\n+\tusrDetails, err := getUserDetail(req)\n \n-\t\tif usr, err := NewUser(usrDetails, a.ApiConfig.Salt); err == nil {\n-\t\t\t//they shouldn't already exist\n-\t\t\tif results, _ := a.Store.FindUsers(usr); results == nil || len(results) == 0 {\n-\t\t\t\tlog.Print(USER_API_PREFIX, \"CreateUser: about to add user\")\n-\t\t\t\ta.addUserAndSendStatus(usr, res, req)\n-\t\t\t\treturn\n-\t\t\t} else {\n-\t\t\t\tlog.Printf(USER_API_PREFIX+\"CreateUser %s \", STATUS_USR_ALREADY_EXISTS)\n-\t\t\t\tsendModelAsResWithStatus(res, status.NewStatus(http.StatusConflict, STATUS_USR_ALREADY_EXISTS), http.StatusConflict)\n-\t\t\t\treturn\n-\t\t\t}\n-\t\t} else {\n-\t\t\tlog.Printf(USER_API_PREFIX+\"CreateUser %s \", err.Error())\n-\t\t}\n+\tif err != nil {\n+\t\tlog.Println(USER_API_PREFIX, \"CreateUser\", STATUS_MISSING_USR_DETAILS, err)\n+\t\tsendModelAsResWithStatus(res, status.NewStatus(http.StatusBadRequest, STATUS_MISSING_USR_DETAILS), http.StatusBadRequest)\n+\t\treturn\n+\t}\n+\n+\tnewUsr, err := NewUser(usrDetails, a.ApiConfig.Salt)\n+\n+\tif err != nil && err == User_error_name_pw_required {","path":"user/api.go","position":29,"original_position":29,"commit_id":"27dc05478fc834004ea48d8c8a401f009117a387","original_commit_id":"27dc05478fc834004ea48d8c8a401f009117a387","user":{"login":"darinkrauss","id":1224433,"avatar_url":"https://avatars.githubusercontent.com/u/1224433?v=3","gravatar_id":"","url":"https://api.github.com/users/darinkrauss","html_url":"https://github.com/darinkrauss","followers_url":"https://api.github.com/users/darinkrauss/followers","following_url":"https://api.github.com/users/darinkrauss/following{/other_user}","gists_url":"https://api.github.com/users/darinkrauss/gists{/gist_id}","starred_url":"https://api.github.com/users/darinkrauss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darinkrauss/subscriptions","organizations_url":"https://api.github.com/users/darinkrauss/orgs","repos_url":"https://api.github.com/users/darinkrauss/repos","events_url":"https://api.github.com/users/darinkrauss/events{/privacy}","received_events_url":"https://api.github.com/users/darinkrauss/received_events","type":"User","site_admin":false},"body":"I would do something like:\r\n\r\n```\r\nif err != nil {\r\n  if err == User_error_name_pw_required {\r\n    // Return one error\r\n  } else {\r\n    // Return the other error\r\n  }\r\n}\r\n```","created_at":"2015-08-07T01:46:27Z","updated_at":"2015-08-07T01:46:27Z","html_url":"https://github.com/tidepool-org/shoreline/pull/21#discussion_r36484908","pull_request_url":"https://api.github.com/repos/tidepool-org/shoreline/pulls/21","_links":{"self":{"href":"https://api.github.com/repos/tidepool-org/shoreline/pulls/comments/36484908"},"html":{"href":"https://github.com/tidepool-org/shoreline/pull/21#discussion_r36484908"},"pull_request":{"href":"https://api.github.com/repos/tidepool-org/shoreline/pulls/21"}}},"pull_request":{"url":"https://api.github.com/repos/tidepool-org/shoreline/pulls/21","id":41852736,"html_url":"https://github.com/tidepool-org/shoreline/pull/21","diff_url":"https://github.com/tidepool-org/shoreline/pull/21.diff","patch_url":"https://github.com/tidepool-org/shoreline/pull/21.patch","issue_url":"https://api.github.com/repos/tidepool-org/shoreline/issues/21","number":21,"state":"open","locked":false,"title":"remove logging from user, return errors and handle in api","user":{"login":"darinkrauss","id":1224433,"avatar_url":"https://avatars.githubusercontent.com/u/1224433?v=3","gravatar_id":"","url":"https://api.github.com/users/darinkrauss","html_url":"https://github.com/darinkrauss","followers_url":"https://api.github.com/users/darinkrauss/followers","following_url":"https://api.github.com/users/darinkrauss/following{/other_user}","gists_url":"https://api.github.com/users/darinkrauss/gists{/gist_id}","starred_url":"https://api.github.com/users/darinkrauss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darinkrauss/subscriptions","organizations_url":"https://api.github.com/users/darinkrauss/orgs","repos_url":"https://api.github.com/users/darinkrauss/repos","events_url":"https://api.github.com/users/darinkrauss/events{/privacy}","received_events_url":"https://api.github.com/users/darinkrauss/received_events","type":"User","site_admin":false},"body":"@jh-bate I used this PR to do a comparison between the token-lifetime branch and the pw-logging branch.  (PR #20 was both #19 plus this and was difficult to grok.)","created_at":"2015-08-07T01:43:11Z","updated_at":"2015-08-07T01:46:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7dc21a76cf67f93983c6b3fc7da9134e7dc14f77","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/tidepool-org/shoreline/pulls/21/commits","review_comments_url":"https://api.github.com/repos/tidepool-org/shoreline/pulls/21/comments","review_comment_url":"https://api.github.com/repos/tidepool-org/shoreline/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tidepool-org/shoreline/issues/21/comments","statuses_url":"https://api.github.com/repos/tidepool-org/shoreline/statuses/27dc05478fc834004ea48d8c8a401f009117a387","head":{"label":"tidepool-org:jhbate/pw-logging","ref":"jhbate/pw-logging","sha":"27dc05478fc834004ea48d8c8a401f009117a387","user":{"login":"tidepool-org","id":4390820,"avatar_url":"https://avatars.githubusercontent.com/u/4390820?v=3","gravatar_id":"","url":"https://api.github.com/users/tidepool-org","html_url":"https://github.com/tidepool-org","followers_url":"https://api.github.com/users/tidepool-org/followers","following_url":"https://api.github.com/users/tidepool-org/following{/other_user}","gists_url":"https://api.github.com/users/tidepool-org/gists{/gist_id}","starred_url":"https://api.github.com/users/tidepool-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tidepool-org/subscriptions","organizations_url":"https://api.github.com/users/tidepool-org/orgs","repos_url":"https://api.github.com/users/tidepool-org/repos","events_url":"https://api.github.com/users/tidepool-org/events{/privacy}","received_events_url":"https://api.github.com/users/tidepool-org/received_events","type":"Organization","site_admin":false},"repo":{"id":21628959,"name":"shoreline","full_name":"tidepool-org/shoreline","owner":{"login":"tidepool-org","id":4390820,"avatar_url":"https://avatars.githubusercontent.com/u/4390820?v=3","gravatar_id":"","url":"https://api.github.com/users/tidepool-org","html_url":"https://github.com/tidepool-org","followers_url":"https://api.github.com/users/tidepool-org/followers","following_url":"https://api.github.com/users/tidepool-org/following{/other_user}","gists_url":"https://api.github.com/users/tidepool-org/gists{/gist_id}","starred_url":"https://api.github.com/users/tidepool-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tidepool-org/subscriptions","organizations_url":"https://api.github.com/users/tidepool-org/orgs","repos_url":"https://api.github.com/users/tidepool-org/repos","events_url":"https://api.github.com/users/tidepool-org/events{/privacy}","received_events_url":"https://api.github.com/users/tidepool-org/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tidepool-org/shoreline","description":"Shoreline is the entrance to the ocean; in our case it manages logins and user accounts","fork":false,"url":"https://api.github.com/repos/tidepool-org/shoreline","forks_url":"https://api.github.com/repos/tidepool-org/shoreline/forks","keys_url":"https://api.github.com/repos/tidepool-org/shoreline/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tidepool-org/shoreline/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tidepool-org/shoreline/teams","hooks_url":"https://api.github.com/repos/tidepool-org/shoreline/hooks","issue_events_url":"https://api.github.com/repos/tidepool-org/shoreline/issues/events{/number}","events_url":"https://api.github.com/repos/tidepool-org/shoreline/events","assignees_url":"https://api.github.com/repos/tidepool-org/shoreline/assignees{/user}","branches_url":"https://api.github.com/repos/tidepool-org/shoreline/branches{/branch}","tags_url":"https://api.github.com/repos/tidepool-org/shoreline/tags","blobs_url":"https://api.github.com/repos/tidepool-org/shoreline/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tidepool-org/shoreline/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tidepool-org/shoreline/git/refs{/sha}","trees_url":"https://api.github.com/repos/tidepool-org/shoreline/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tidepool-org/shoreline/statuses/{sha}","languages_url":"https://api.github.com/repos/tidepool-org/shoreline/languages","stargazers_url":"https://api.github.com/repos/tidepool-org/shoreline/stargazers","contributors_url":"https://api.github.com/repos/tidepool-org/shoreline/contributors","subscribers_url":"https://api.github.com/repos/tidepool-org/shoreline/subscribers","subscription_url":"https://api.github.com/repos/tidepool-org/shoreline/subscription","commits_url":"https://api.github.com/repos/tidepool-org/shoreline/commits{/sha}","git_commits_url":"https://api.github.com/repos/tidepool-org/shoreline/git/commits{/sha}","comments_url":"https://api.github.com/repos/tidepool-org/shoreline/comments{/number}","issue_comment_url":"https://api.github.com/repos/tidepool-org/shoreline/issues/comments{/number}","contents_url":"https://api.github.com/repos/tidepool-org/shoreline/contents/{+path}","compare_url":"https://api.github.com/repos/tidepool-org/shoreline/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tidepool-org/shoreline/merges","archive_url":"https://api.github.com/repos/tidepool-org/shoreline/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tidepool-org/shoreline/downloads","issues_url":"https://api.github.com/repos/tidepool-org/shoreline/issues{/number}","pulls_url":"https://api.github.com/repos/tidepool-org/shoreline/pulls{/number}","milestones_url":"https://api.github.com/repos/tidepool-org/shoreline/milestones{/number}","notifications_url":"https://api.github.com/repos/tidepool-org/shoreline/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tidepool-org/shoreline/labels{/name}","releases_url":"https://api.github.com/repos/tidepool-org/shoreline/releases{/id}","created_at":"2014-07-08T20:47:07Z","updated_at":"2015-04-30T00:04:19Z","pushed_at":"2015-08-07T01:43:11Z","git_url":"git://github.com/tidepool-org/shoreline.git","ssh_url":"git@github.com:tidepool-org/shoreline.git","clone_url":"https://github.com/tidepool-org/shoreline.git","svn_url":"https://github.com/tidepool-org/shoreline","homepage":null,"size":1323,"stargazers_count":1,"watchers_count":1,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":5,"forks":2,"open_issues":5,"watchers":1,"default_branch":"master"}},"base":{"label":"tidepool-org:jhbate/token-lifetime","ref":"jhbate/token-lifetime","sha":"7eeeeac221ca2b764c9de095dee72f036fd34b25","user":{"login":"tidepool-org","id":4390820,"avatar_url":"https://avatars.githubusercontent.com/u/4390820?v=3","gravatar_id":"","url":"https://api.github.com/users/tidepool-org","html_url":"https://github.com/tidepool-org","followers_url":"https://api.github.com/users/tidepool-org/followers","following_url":"https://api.github.com/users/tidepool-org/following{/other_user}","gists_url":"https://api.github.com/users/tidepool-org/gists{/gist_id}","starred_url":"https://api.github.com/users/tidepool-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tidepool-org/subscriptions","organizations_url":"https://api.github.com/users/tidepool-org/orgs","repos_url":"https://api.github.com/users/tidepool-org/repos","events_url":"https://api.github.com/users/tidepool-org/events{/privacy}","received_events_url":"https://api.github.com/users/tidepool-org/received_events","type":"Organization","site_admin":false},"repo":{"id":21628959,"name":"shoreline","full_name":"tidepool-org/shoreline","owner":{"login":"tidepool-org","id":4390820,"avatar_url":"https://avatars.githubusercontent.com/u/4390820?v=3","gravatar_id":"","url":"https://api.github.com/users/tidepool-org","html_url":"https://github.com/tidepool-org","followers_url":"https://api.github.com/users/tidepool-org/followers","following_url":"https://api.github.com/users/tidepool-org/following{/other_user}","gists_url":"https://api.github.com/users/tidepool-org/gists{/gist_id}","starred_url":"https://api.github.com/users/tidepool-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tidepool-org/subscriptions","organizations_url":"https://api.github.com/users/tidepool-org/orgs","repos_url":"https://api.github.com/users/tidepool-org/repos","events_url":"https://api.github.com/users/tidepool-org/events{/privacy}","received_events_url":"https://api.github.com/users/tidepool-org/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tidepool-org/shoreline","description":"Shoreline is the entrance to the ocean; in our case it manages logins and user accounts","fork":false,"url":"https://api.github.com/repos/tidepool-org/shoreline","forks_url":"https://api.github.com/repos/tidepool-org/shoreline/forks","keys_url":"https://api.github.com/repos/tidepool-org/shoreline/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tidepool-org/shoreline/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tidepool-org/shoreline/teams","hooks_url":"https://api.github.com/repos/tidepool-org/shoreline/hooks","issue_events_url":"https://api.github.com/repos/tidepool-org/shoreline/issues/events{/number}","events_url":"https://api.github.com/repos/tidepool-org/shoreline/events","assignees_url":"https://api.github.com/repos/tidepool-org/shoreline/assignees{/user}","branches_url":"https://api.github.com/repos/tidepool-org/shoreline/branches{/branch}","tags_url":"https://api.github.com/repos/tidepool-org/shoreline/tags","blobs_url":"https://api.github.com/repos/tidepool-org/shoreline/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tidepool-org/shoreline/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tidepool-org/shoreline/git/refs{/sha}","trees_url":"https://api.github.com/repos/tidepool-org/shoreline/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tidepool-org/shoreline/statuses/{sha}","languages_url":"https://api.github.com/repos/tidepool-org/shoreline/languages","stargazers_url":"https://api.github.com/repos/tidepool-org/shoreline/stargazers","contributors_url":"https://api.github.com/repos/tidepool-org/shoreline/contributors","subscribers_url":"https://api.github.com/repos/tidepool-org/shoreline/subscribers","subscription_url":"https://api.github.com/repos/tidepool-org/shoreline/subscription","commits_url":"https://api.github.com/repos/tidepool-org/shoreline/commits{/sha}","git_commits_url":"https://api.github.com/repos/tidepool-org/shoreline/git/commits{/sha}","comments_url":"https://api.github.com/repos/tidepool-org/shoreline/comments{/number}","issue_comment_url":"https://api.github.com/repos/tidepool-org/shoreline/issues/comments{/number}","contents_url":"https://api.github.com/repos/tidepool-org/shoreline/contents/{+path}","compare_url":"https://api.github.com/repos/tidepool-org/shoreline/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tidepool-org/shoreline/merges","archive_url":"https://api.github.com/repos/tidepool-org/shoreline/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tidepool-org/shoreline/downloads","issues_url":"https://api.github.com/repos/tidepool-org/shoreline/issues{/number}","pulls_url":"https://api.github.com/repos/tidepool-org/shoreline/pulls{/number}","milestones_url":"https://api.github.com/repos/tidepool-org/shoreline/milestones{/number}","notifications_url":"https://api.github.com/repos/tidepool-org/shoreline/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tidepool-org/shoreline/labels{/name}","releases_url":"https://api.github.com/repos/tidepool-org/shoreline/releases{/id}","created_at":"2014-07-08T20:47:07Z","updated_at":"2015-04-30T00:04:19Z","pushed_at":"2015-08-07T01:43:11Z","git_url":"git://github.com/tidepool-org/shoreline.git","ssh_url":"git@github.com:tidepool-org/shoreline.git","clone_url":"https://github.com/tidepool-org/shoreline.git","svn_url":"https://github.com/tidepool-org/shoreline","homepage":null,"size":1323,"stargazers_count":1,"watchers_count":1,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":5,"forks":2,"open_issues":5,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tidepool-org/shoreline/pulls/21"},"html":{"href":"https://github.com/tidepool-org/shoreline/pull/21"},"issue":{"href":"https://api.github.com/repos/tidepool-org/shoreline/issues/21"},"comments":{"href":"https://api.github.com/repos/tidepool-org/shoreline/issues/21/comments"},"review_comments":{"href":"https://api.github.com/repos/tidepool-org/shoreline/pulls/21/comments"},"review_comment":{"href":"https://api.github.com/repos/tidepool-org/shoreline/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tidepool-org/shoreline/pulls/21/commits"},"statuses":{"href":"https://api.github.com/repos/tidepool-org/shoreline/statuses/27dc05478fc834004ea48d8c8a401f009117a387"}}}}