{"action":"created","comment":{"url":"https://api.github.com/repos/reddit/reddit-mobile/pulls/comments/53352444","id":53352444,"diff_hunk":"@@ -0,0 +1,152 @@\n+import React from 'react';\n+import superagent from 'superagent';\n+import has from 'lodash/object/has';\n+\n+import constants from '../../constants';\n+\n+const T = React.PropTypes;\n+\n+import BaseComponent from './BaseComponent';\n+import MinimalInput from './formElements/minimalinput';\n+import SquareButton from './formElements/SquareButton';\n+\n+const EmailWarning = 'Unfortunately if you have never given us your email,' +\n+                     ' we will not be able to reset your password';\n+\n+\n+const ERRORS = {\n+  USER_DOESNT_EXIST: 'Sorry, this user does not exist.',\n+  NO_EMAIL_FOR_USER: 'Sorry, there is no email for this user.',\n+  RATELIMIT: 'Sorry, you are doing that too much.',\n+  504: 'Sorry, it took too long for the server to respond',\n+  500: 'Sorry, something has gone wrong with the server',\n+  DEFAULT: 'Sorry, Something has gone wrong and we\\'re not sure what',\n+};\n+\n+class ForgotPassword extends BaseComponent {\n+  static propTypes = {\n+    app: T.object.isRequired,\n+  };\n+\n+  constructor(props) {\n+    super(props);\n+\n+    this.submitForm = this.submitForm.bind(this);\n+    this.updateName = this.updateName.bind(this);\n+    this.makeRequest = this.makeRequest.bind(this);\n+    this.requestReset = this.requestReset.bind(this);\n+    this.renderClear = this.renderClear.bind(this);\n+    this.clear = this.clear.bind(this);\n+  }\n+\n+  submitForm(e) {\n+    e.preventDefault();\n+    const name = this.state.name;\n+\n+    if (name) {\n+      this.requestReset(name);\n+    }\n+  }\n+\n+  async requestReset(name) {\n+    try {\n+      const { nonAuthAPIOrigin } = this.props.app.config;\n+      const uri = '/api/password.json';\n+\n+      const postData = {\n+        name,\n+        api_type: 'json',\n+      };\n+\n+      const res = await this.makeRequest(nonAuthAPIOrigin + uri, postData);\n+\n+      if (res) {\n+        // show message\n+        this.props.close();\n+      }\n+    } catch (e) {\n+      this.setState({\n+        error: ERRORS[e.name] ||\n+               ERRORS[e.status] ||\n+               ERRORS.DEFAULT,\n+      });\n+    }\n+  }\n+\n+  async makeRequest(uri, postData) {\n+    return await new Promise(async function(resolve, reject) {","path":"src/views/components/forgotpassword.jsx","position":77,"original_position":77,"commit_id":"fbb2eb7b46cdc536fc9c9014231d8fba625afe71","original_commit_id":"fbb2eb7b46cdc536fc9c9014231d8fba625afe71","user":{"login":"ajacksified","id":175515,"avatar_url":"https://avatars.githubusercontent.com/u/175515?v=3","gravatar_id":"","url":"https://api.github.com/users/ajacksified","html_url":"https://github.com/ajacksified","followers_url":"https://api.github.com/users/ajacksified/followers","following_url":"https://api.github.com/users/ajacksified/following{/other_user}","gists_url":"https://api.github.com/users/ajacksified/gists{/gist_id}","starred_url":"https://api.github.com/users/ajacksified/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajacksified/subscriptions","organizations_url":"https://api.github.com/users/ajacksified/orgs","repos_url":"https://api.github.com/users/ajacksified/repos","events_url":"https://api.github.com/users/ajacksified/events{/privacy}","received_events_url":"https://api.github.com/users/ajacksified/received_events","type":"User","site_admin":false},"body":"Or, we switch to fetch \\o/","created_at":"2016-02-18T17:51:53Z","updated_at":"2016-02-18T17:51:53Z","html_url":"https://github.com/reddit/reddit-mobile/pull/477#discussion_r53352444","pull_request_url":"https://api.github.com/repos/reddit/reddit-mobile/pulls/477","_links":{"self":{"href":"https://api.github.com/repos/reddit/reddit-mobile/pulls/comments/53352444"},"html":{"href":"https://github.com/reddit/reddit-mobile/pull/477#discussion_r53352444"},"pull_request":{"href":"https://api.github.com/repos/reddit/reddit-mobile/pulls/477"}}},"pull_request":{"url":"https://api.github.com/repos/reddit/reddit-mobile/pulls/477","id":57922145,"html_url":"https://github.com/reddit/reddit-mobile/pull/477","diff_url":"https://github.com/reddit/reddit-mobile/pull/477.diff","patch_url":"https://github.com/reddit/reddit-mobile/pull/477.patch","issue_url":"https://api.github.com/repos/reddit/reddit-mobile/issues/477","number":477,"state":"open","locked":false,"title":"Restyle register","user":{"login":"curioussavage","id":7064600,"avatar_url":"https://avatars.githubusercontent.com/u/7064600?v=3","gravatar_id":"","url":"https://api.github.com/users/curioussavage","html_url":"https://github.com/curioussavage","followers_url":"https://api.github.com/users/curioussavage/followers","following_url":"https://api.github.com/users/curioussavage/following{/other_user}","gists_url":"https://api.github.com/users/curioussavage/gists{/gist_id}","starred_url":"https://api.github.com/users/curioussavage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/curioussavage/subscriptions","organizations_url":"https://api.github.com/users/curioussavage/orgs","repos_url":"https://api.github.com/users/curioussavage/repos","events_url":"https://api.github.com/users/curioussavage/events{/privacy}","received_events_url":"https://api.github.com/users/curioussavage/received_events","type":"User","site_admin":false},"body":"work in progress...","created_at":"2016-02-02T00:17:51Z","updated_at":"2016-02-18T17:51:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d23a4b11c56cfe4f45688fbf9c8d402522d37c65","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/reddit/reddit-mobile/pulls/477/commits","review_comments_url":"https://api.github.com/repos/reddit/reddit-mobile/pulls/477/comments","review_comment_url":"https://api.github.com/repos/reddit/reddit-mobile/pulls/comments{/number}","comments_url":"https://api.github.com/repos/reddit/reddit-mobile/issues/477/comments","statuses_url":"https://api.github.com/repos/reddit/reddit-mobile/statuses/fbb2eb7b46cdc536fc9c9014231d8fba625afe71","head":{"label":"curioussavage:restyle-register","ref":"restyle-register","sha":"fbb2eb7b46cdc536fc9c9014231d8fba625afe71","user":{"login":"curioussavage","id":7064600,"avatar_url":"https://avatars.githubusercontent.com/u/7064600?v=3","gravatar_id":"","url":"https://api.github.com/users/curioussavage","html_url":"https://github.com/curioussavage","followers_url":"https://api.github.com/users/curioussavage/followers","following_url":"https://api.github.com/users/curioussavage/following{/other_user}","gists_url":"https://api.github.com/users/curioussavage/gists{/gist_id}","starred_url":"https://api.github.com/users/curioussavage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/curioussavage/subscriptions","organizations_url":"https://api.github.com/users/curioussavage/orgs","repos_url":"https://api.github.com/users/curioussavage/repos","events_url":"https://api.github.com/users/curioussavage/events{/privacy}","received_events_url":"https://api.github.com/users/curioussavage/received_events","type":"User","site_admin":false},"repo":{"id":35171597,"name":"reddit-mobile","full_name":"curioussavage/reddit-mobile","owner":{"login":"curioussavage","id":7064600,"avatar_url":"https://avatars.githubusercontent.com/u/7064600?v=3","gravatar_id":"","url":"https://api.github.com/users/curioussavage","html_url":"https://github.com/curioussavage","followers_url":"https://api.github.com/users/curioussavage/followers","following_url":"https://api.github.com/users/curioussavage/following{/other_user}","gists_url":"https://api.github.com/users/curioussavage/gists{/gist_id}","starred_url":"https://api.github.com/users/curioussavage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/curioussavage/subscriptions","organizations_url":"https://api.github.com/users/curioussavage/orgs","repos_url":"https://api.github.com/users/curioussavage/repos","events_url":"https://api.github.com/users/curioussavage/events{/privacy}","received_events_url":"https://api.github.com/users/curioussavage/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/curioussavage/reddit-mobile","description":"","fork":true,"url":"https://api.github.com/repos/curioussavage/reddit-mobile","forks_url":"https://api.github.com/repos/curioussavage/reddit-mobile/forks","keys_url":"https://api.github.com/repos/curioussavage/reddit-mobile/keys{/key_id}","collaborators_url":"https://api.github.com/repos/curioussavage/reddit-mobile/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/curioussavage/reddit-mobile/teams","hooks_url":"https://api.github.com/repos/curioussavage/reddit-mobile/hooks","issue_events_url":"https://api.github.com/repos/curioussavage/reddit-mobile/issues/events{/number}","events_url":"https://api.github.com/repos/curioussavage/reddit-mobile/events","assignees_url":"https://api.github.com/repos/curioussavage/reddit-mobile/assignees{/user}","branches_url":"https://api.github.com/repos/curioussavage/reddit-mobile/branches{/branch}","tags_url":"https://api.github.com/repos/curioussavage/reddit-mobile/tags","blobs_url":"https://api.github.com/repos/curioussavage/reddit-mobile/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/curioussavage/reddit-mobile/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/curioussavage/reddit-mobile/git/refs{/sha}","trees_url":"https://api.github.com/repos/curioussavage/reddit-mobile/git/trees{/sha}","statuses_url":"https://api.github.com/repos/curioussavage/reddit-mobile/statuses/{sha}","languages_url":"https://api.github.com/repos/curioussavage/reddit-mobile/languages","stargazers_url":"https://api.github.com/repos/curioussavage/reddit-mobile/stargazers","contributors_url":"https://api.github.com/repos/curioussavage/reddit-mobile/contributors","subscribers_url":"https://api.github.com/repos/curioussavage/reddit-mobile/subscribers","subscription_url":"https://api.github.com/repos/curioussavage/reddit-mobile/subscription","commits_url":"https://api.github.com/repos/curioussavage/reddit-mobile/commits{/sha}","git_commits_url":"https://api.github.com/repos/curioussavage/reddit-mobile/git/commits{/sha}","comments_url":"https://api.github.com/repos/curioussavage/reddit-mobile/comments{/number}","issue_comment_url":"https://api.github.com/repos/curioussavage/reddit-mobile/issues/comments{/number}","contents_url":"https://api.github.com/repos/curioussavage/reddit-mobile/contents/{+path}","compare_url":"https://api.github.com/repos/curioussavage/reddit-mobile/compare/{base}...{head}","merges_url":"https://api.github.com/repos/curioussavage/reddit-mobile/merges","archive_url":"https://api.github.com/repos/curioussavage/reddit-mobile/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/curioussavage/reddit-mobile/downloads","issues_url":"https://api.github.com/repos/curioussavage/reddit-mobile/issues{/number}","pulls_url":"https://api.github.com/repos/curioussavage/reddit-mobile/pulls{/number}","milestones_url":"https://api.github.com/repos/curioussavage/reddit-mobile/milestones{/number}","notifications_url":"https://api.github.com/repos/curioussavage/reddit-mobile/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/curioussavage/reddit-mobile/labels{/name}","releases_url":"https://api.github.com/repos/curioussavage/reddit-mobile/releases{/id}","deployments_url":"https://api.github.com/repos/curioussavage/reddit-mobile/deployments","created_at":"2015-05-06T16:55:50Z","updated_at":"2016-01-21T19:27:43Z","pushed_at":"2016-02-18T00:22:47Z","git_url":"git://github.com/curioussavage/reddit-mobile.git","ssh_url":"git@github.com:curioussavage/reddit-mobile.git","clone_url":"https://github.com/curioussavage/reddit-mobile.git","svn_url":"https://github.com/curioussavage/reddit-mobile","homepage":null,"size":3124,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"reddit:master","ref":"master","sha":"4f74d6172caf0b743cf0d92c7daf06578fc2daf6","user":{"login":"reddit","id":14248,"avatar_url":"https://avatars.githubusercontent.com/u/14248?v=3","gravatar_id":"","url":"https://api.github.com/users/reddit","html_url":"https://github.com/reddit","followers_url":"https://api.github.com/users/reddit/followers","following_url":"https://api.github.com/users/reddit/following{/other_user}","gists_url":"https://api.github.com/users/reddit/gists{/gist_id}","starred_url":"https://api.github.com/users/reddit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reddit/subscriptions","organizations_url":"https://api.github.com/users/reddit/orgs","repos_url":"https://api.github.com/users/reddit/repos","events_url":"https://api.github.com/users/reddit/events{/privacy}","received_events_url":"https://api.github.com/users/reddit/received_events","type":"Organization","site_admin":false},"repo":{"id":23087554,"name":"reddit-mobile","full_name":"reddit/reddit-mobile","owner":{"login":"reddit","id":14248,"avatar_url":"https://avatars.githubusercontent.com/u/14248?v=3","gravatar_id":"","url":"https://api.github.com/users/reddit","html_url":"https://github.com/reddit","followers_url":"https://api.github.com/users/reddit/followers","following_url":"https://api.github.com/users/reddit/following{/other_user}","gists_url":"https://api.github.com/users/reddit/gists{/gist_id}","starred_url":"https://api.github.com/users/reddit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reddit/subscriptions","organizations_url":"https://api.github.com/users/reddit/orgs","repos_url":"https://api.github.com/users/reddit/repos","events_url":"https://api.github.com/users/reddit/events{/privacy}","received_events_url":"https://api.github.com/users/reddit/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/reddit/reddit-mobile","description":"","fork":false,"url":"https://api.github.com/repos/reddit/reddit-mobile","forks_url":"https://api.github.com/repos/reddit/reddit-mobile/forks","keys_url":"https://api.github.com/repos/reddit/reddit-mobile/keys{/key_id}","collaborators_url":"https://api.github.com/repos/reddit/reddit-mobile/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/reddit/reddit-mobile/teams","hooks_url":"https://api.github.com/repos/reddit/reddit-mobile/hooks","issue_events_url":"https://api.github.com/repos/reddit/reddit-mobile/issues/events{/number}","events_url":"https://api.github.com/repos/reddit/reddit-mobile/events","assignees_url":"https://api.github.com/repos/reddit/reddit-mobile/assignees{/user}","branches_url":"https://api.github.com/repos/reddit/reddit-mobile/branches{/branch}","tags_url":"https://api.github.com/repos/reddit/reddit-mobile/tags","blobs_url":"https://api.github.com/repos/reddit/reddit-mobile/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/reddit/reddit-mobile/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/reddit/reddit-mobile/git/refs{/sha}","trees_url":"https://api.github.com/repos/reddit/reddit-mobile/git/trees{/sha}","statuses_url":"https://api.github.com/repos/reddit/reddit-mobile/statuses/{sha}","languages_url":"https://api.github.com/repos/reddit/reddit-mobile/languages","stargazers_url":"https://api.github.com/repos/reddit/reddit-mobile/stargazers","contributors_url":"https://api.github.com/repos/reddit/reddit-mobile/contributors","subscribers_url":"https://api.github.com/repos/reddit/reddit-mobile/subscribers","subscription_url":"https://api.github.com/repos/reddit/reddit-mobile/subscription","commits_url":"https://api.github.com/repos/reddit/reddit-mobile/commits{/sha}","git_commits_url":"https://api.github.com/repos/reddit/reddit-mobile/git/commits{/sha}","comments_url":"https://api.github.com/repos/reddit/reddit-mobile/comments{/number}","issue_comment_url":"https://api.github.com/repos/reddit/reddit-mobile/issues/comments{/number}","contents_url":"https://api.github.com/repos/reddit/reddit-mobile/contents/{+path}","compare_url":"https://api.github.com/repos/reddit/reddit-mobile/compare/{base}...{head}","merges_url":"https://api.github.com/repos/reddit/reddit-mobile/merges","archive_url":"https://api.github.com/repos/reddit/reddit-mobile/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/reddit/reddit-mobile/downloads","issues_url":"https://api.github.com/repos/reddit/reddit-mobile/issues{/number}","pulls_url":"https://api.github.com/repos/reddit/reddit-mobile/pulls{/number}","milestones_url":"https://api.github.com/repos/reddit/reddit-mobile/milestones{/number}","notifications_url":"https://api.github.com/repos/reddit/reddit-mobile/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/reddit/reddit-mobile/labels{/name}","releases_url":"https://api.github.com/repos/reddit/reddit-mobile/releases{/id}","deployments_url":"https://api.github.com/repos/reddit/reddit-mobile/deployments","created_at":"2014-08-18T21:42:05Z","updated_at":"2016-02-18T16:37:55Z","pushed_at":"2016-02-18T00:55:41Z","git_url":"git://github.com/reddit/reddit-mobile.git","ssh_url":"git@github.com:reddit/reddit-mobile.git","clone_url":"https://github.com/reddit/reddit-mobile.git","svn_url":"https://github.com/reddit/reddit-mobile","homepage":null,"size":6509,"stargazers_count":695,"watchers_count":695,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":109,"mirror_url":null,"open_issues_count":12,"forks":109,"open_issues":12,"watchers":695,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/reddit/reddit-mobile/pulls/477"},"html":{"href":"https://github.com/reddit/reddit-mobile/pull/477"},"issue":{"href":"https://api.github.com/repos/reddit/reddit-mobile/issues/477"},"comments":{"href":"https://api.github.com/repos/reddit/reddit-mobile/issues/477/comments"},"review_comments":{"href":"https://api.github.com/repos/reddit/reddit-mobile/pulls/477/comments"},"review_comment":{"href":"https://api.github.com/repos/reddit/reddit-mobile/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/reddit/reddit-mobile/pulls/477/commits"},"statuses":{"href":"https://api.github.com/repos/reddit/reddit-mobile/statuses/fbb2eb7b46cdc536fc9c9014231d8fba625afe71"}}}}