{"action":"created","comment":{"url":"https://api.github.com/repos/dangvanhieu2/Chapter3/pulls/comments/111046761","pull_request_review_id":32262802,"id":111046761,"diff_hunk":"@@ -0,0 +1,62 @@\n+class PasswordResetsController < ApplicationController\n+  before_action :get_user, only: [:edit, :update]\n+  before_action :valid_user, only: [:edit, :update]\n+  before_action :check_expiration, only: [:edit, :update]\n+\n+  def new\n+  end\n+\n+  def create\n+    @user = User.find_by email: params[:password_reset][:email].downcase\n+    if @user\n+      @user.create_reset_digest\n+      @user.send_password_reset_email\n+      flash[:info] = I18n.t(\"email_sent_with_password_reset\")\n+      redirect_to root_url\n+    else\n+      flash.now[:danger] = I18n.t(\"email_not_found\")\n+      render :new\n+    end\n+  end\n+\n+  def edit\n+  end\n+\n+  def update\n+    if params[:user][:password].empty?\n+      @user.errors.add :password, I18n.t(\"can_not_be_empty\")\n+      render :edit\n+    elsif @user.update_attributes user_params\n+      log_in @user\n+      @user.update_attribute :reset_digest, nil\n+      flash[:success] = I18n.t(\"password_has_been_reset\")\n+      redirect_to @user\n+    else\n+      render :edit\n+    end\n+  end\n+\n+  private\n+\n+  def user_params\n+    params.require(:user).permit :password, :password_confirmation\n+  end\n+\n+  def get_user\n+    @user = User.find_by email: params[:email]\n+  end\n+\n+  def valid_user\n+    unless @user && @user.activated? &&\n+      @user.authenticated?(:reset, params[:id])\n+      redirect_to root_url\n+    end\n+  end\n+\n+  def check_expiration\n+    if @user.password_reset_expired?\n+      flash[:danger] = I18n.t(\"password_reset_has_expired\")","path":"app/controllers/password_resets_controller.rb","position":58,"original_position":58,"commit_id":"09394d313f7b4421353ff3db8cc113e538a9e94e","original_commit_id":"09394d313f7b4421353ff3db8cc113e538a9e94e","user":{"login":"dangvanhieu2","id":26705854,"avatar_url":"https://avatars2.githubusercontent.com/u/26705854?v=3","gravatar_id":"","url":"https://api.github.com/users/dangvanhieu2","html_url":"https://github.com/dangvanhieu2","followers_url":"https://api.github.com/users/dangvanhieu2/followers","following_url":"https://api.github.com/users/dangvanhieu2/following{/other_user}","gists_url":"https://api.github.com/users/dangvanhieu2/gists{/gist_id}","starred_url":"https://api.github.com/users/dangvanhieu2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dangvanhieu2/subscriptions","organizations_url":"https://api.github.com/users/dangvanhieu2/orgs","repos_url":"https://api.github.com/users/dangvanhieu2/repos","events_url":"https://api.github.com/users/dangvanhieu2/events{/privacy}","received_events_url":"https://api.github.com/users/dangvanhieu2/received_events","type":"User","site_admin":false},"body":"Fixed","created_at":"2017-04-12T00:59:07Z","updated_at":"2017-04-12T00:59:07Z","html_url":"https://github.com/dangvanhieu2/Chapter3/pull/10#discussion_r111046761","pull_request_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/pulls/10","_links":{"self":{"href":"https://api.github.com/repos/dangvanhieu2/Chapter3/pulls/comments/111046761"},"html":{"href":"https://github.com/dangvanhieu2/Chapter3/pull/10#discussion_r111046761"},"pull_request":{"href":"https://api.github.com/repos/dangvanhieu2/Chapter3/pulls/10"}}},"pull_request":{"url":"https://api.github.com/repos/dangvanhieu2/Chapter3/pulls/10","id":115286002,"html_url":"https://github.com/dangvanhieu2/Chapter3/pull/10","diff_url":"https://github.com/dangvanhieu2/Chapter3/pull/10.diff","patch_url":"https://github.com/dangvanhieu2/Chapter3/pull/10.patch","issue_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/issues/10","number":10,"state":"open","locked":false,"title":"Chapter 12: Password reset","user":{"login":"dangvanhieu2","id":26705854,"avatar_url":"https://avatars2.githubusercontent.com/u/26705854?v=3","gravatar_id":"","url":"https://api.github.com/users/dangvanhieu2","html_url":"https://github.com/dangvanhieu2","followers_url":"https://api.github.com/users/dangvanhieu2/followers","following_url":"https://api.github.com/users/dangvanhieu2/following{/other_user}","gists_url":"https://api.github.com/users/dangvanhieu2/gists{/gist_id}","starred_url":"https://api.github.com/users/dangvanhieu2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dangvanhieu2/subscriptions","organizations_url":"https://api.github.com/users/dangvanhieu2/orgs","repos_url":"https://api.github.com/users/dangvanhieu2/repos","events_url":"https://api.github.com/users/dangvanhieu2/events{/privacy}","received_events_url":"https://api.github.com/users/dangvanhieu2/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-04-11T10:14:36Z","updated_at":"2017-04-12T00:59:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"368c8f3b99f339411e3467e2c037c788513508cf","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/pulls/10/commits","review_comments_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/pulls/10/comments","review_comment_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/issues/10/comments","statuses_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/statuses/09394d313f7b4421353ff3db8cc113e538a9e94e","head":{"label":"dangvanhieu2:chapter12","ref":"chapter12","sha":"09394d313f7b4421353ff3db8cc113e538a9e94e","user":{"login":"dangvanhieu2","id":26705854,"avatar_url":"https://avatars2.githubusercontent.com/u/26705854?v=3","gravatar_id":"","url":"https://api.github.com/users/dangvanhieu2","html_url":"https://github.com/dangvanhieu2","followers_url":"https://api.github.com/users/dangvanhieu2/followers","following_url":"https://api.github.com/users/dangvanhieu2/following{/other_user}","gists_url":"https://api.github.com/users/dangvanhieu2/gists{/gist_id}","starred_url":"https://api.github.com/users/dangvanhieu2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dangvanhieu2/subscriptions","organizations_url":"https://api.github.com/users/dangvanhieu2/orgs","repos_url":"https://api.github.com/users/dangvanhieu2/repos","events_url":"https://api.github.com/users/dangvanhieu2/events{/privacy}","received_events_url":"https://api.github.com/users/dangvanhieu2/received_events","type":"User","site_admin":false},"repo":{"id":87614887,"name":"Chapter3","full_name":"dangvanhieu2/Chapter3","owner":{"login":"dangvanhieu2","id":26705854,"avatar_url":"https://avatars2.githubusercontent.com/u/26705854?v=3","gravatar_id":"","url":"https://api.github.com/users/dangvanhieu2","html_url":"https://github.com/dangvanhieu2","followers_url":"https://api.github.com/users/dangvanhieu2/followers","following_url":"https://api.github.com/users/dangvanhieu2/following{/other_user}","gists_url":"https://api.github.com/users/dangvanhieu2/gists{/gist_id}","starred_url":"https://api.github.com/users/dangvanhieu2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dangvanhieu2/subscriptions","organizations_url":"https://api.github.com/users/dangvanhieu2/orgs","repos_url":"https://api.github.com/users/dangvanhieu2/repos","events_url":"https://api.github.com/users/dangvanhieu2/events{/privacy}","received_events_url":"https://api.github.com/users/dangvanhieu2/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dangvanhieu2/Chapter3","description":null,"fork":false,"url":"https://api.github.com/repos/dangvanhieu2/Chapter3","forks_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/forks","keys_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/teams","hooks_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/hooks","issue_events_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/issues/events{/number}","events_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/events","assignees_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/assignees{/user}","branches_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/branches{/branch}","tags_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/tags","blobs_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/git/refs{/sha}","trees_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/statuses/{sha}","languages_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/languages","stargazers_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/stargazers","contributors_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/contributors","subscribers_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/subscribers","subscription_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/subscription","commits_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/commits{/sha}","git_commits_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/git/commits{/sha}","comments_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/comments{/number}","issue_comment_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/issues/comments{/number}","contents_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/contents/{+path}","compare_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/merges","archive_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/downloads","issues_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/issues{/number}","pulls_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/pulls{/number}","milestones_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/milestones{/number}","notifications_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/labels{/name}","releases_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/releases{/id}","deployments_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/deployments","created_at":"2017-04-08T06:58:45Z","updated_at":"2017-04-08T07:00:49Z","pushed_at":"2017-04-11T10:46:32Z","git_url":"git://github.com/dangvanhieu2/Chapter3.git","ssh_url":"git@github.com:dangvanhieu2/Chapter3.git","clone_url":"https://github.com/dangvanhieu2/Chapter3.git","svn_url":"https://github.com/dangvanhieu2/Chapter3","homepage":null,"size":72,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"dangvanhieu2:master","ref":"master","sha":"5c0df18c884cf834b3accfadd39b291afe1d3a08","user":{"login":"dangvanhieu2","id":26705854,"avatar_url":"https://avatars2.githubusercontent.com/u/26705854?v=3","gravatar_id":"","url":"https://api.github.com/users/dangvanhieu2","html_url":"https://github.com/dangvanhieu2","followers_url":"https://api.github.com/users/dangvanhieu2/followers","following_url":"https://api.github.com/users/dangvanhieu2/following{/other_user}","gists_url":"https://api.github.com/users/dangvanhieu2/gists{/gist_id}","starred_url":"https://api.github.com/users/dangvanhieu2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dangvanhieu2/subscriptions","organizations_url":"https://api.github.com/users/dangvanhieu2/orgs","repos_url":"https://api.github.com/users/dangvanhieu2/repos","events_url":"https://api.github.com/users/dangvanhieu2/events{/privacy}","received_events_url":"https://api.github.com/users/dangvanhieu2/received_events","type":"User","site_admin":false},"repo":{"id":87614887,"name":"Chapter3","full_name":"dangvanhieu2/Chapter3","owner":{"login":"dangvanhieu2","id":26705854,"avatar_url":"https://avatars2.githubusercontent.com/u/26705854?v=3","gravatar_id":"","url":"https://api.github.com/users/dangvanhieu2","html_url":"https://github.com/dangvanhieu2","followers_url":"https://api.github.com/users/dangvanhieu2/followers","following_url":"https://api.github.com/users/dangvanhieu2/following{/other_user}","gists_url":"https://api.github.com/users/dangvanhieu2/gists{/gist_id}","starred_url":"https://api.github.com/users/dangvanhieu2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dangvanhieu2/subscriptions","organizations_url":"https://api.github.com/users/dangvanhieu2/orgs","repos_url":"https://api.github.com/users/dangvanhieu2/repos","events_url":"https://api.github.com/users/dangvanhieu2/events{/privacy}","received_events_url":"https://api.github.com/users/dangvanhieu2/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dangvanhieu2/Chapter3","description":null,"fork":false,"url":"https://api.github.com/repos/dangvanhieu2/Chapter3","forks_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/forks","keys_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/teams","hooks_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/hooks","issue_events_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/issues/events{/number}","events_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/events","assignees_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/assignees{/user}","branches_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/branches{/branch}","tags_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/tags","blobs_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/git/refs{/sha}","trees_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/statuses/{sha}","languages_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/languages","stargazers_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/stargazers","contributors_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/contributors","subscribers_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/subscribers","subscription_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/subscription","commits_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/commits{/sha}","git_commits_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/git/commits{/sha}","comments_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/comments{/number}","issue_comment_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/issues/comments{/number}","contents_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/contents/{+path}","compare_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/merges","archive_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/downloads","issues_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/issues{/number}","pulls_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/pulls{/number}","milestones_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/milestones{/number}","notifications_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/labels{/name}","releases_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/releases{/id}","deployments_url":"https://api.github.com/repos/dangvanhieu2/Chapter3/deployments","created_at":"2017-04-08T06:58:45Z","updated_at":"2017-04-08T07:00:49Z","pushed_at":"2017-04-11T10:46:32Z","git_url":"git://github.com/dangvanhieu2/Chapter3.git","ssh_url":"git@github.com:dangvanhieu2/Chapter3.git","clone_url":"https://github.com/dangvanhieu2/Chapter3.git","svn_url":"https://github.com/dangvanhieu2/Chapter3","homepage":null,"size":72,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dangvanhieu2/Chapter3/pulls/10"},"html":{"href":"https://github.com/dangvanhieu2/Chapter3/pull/10"},"issue":{"href":"https://api.github.com/repos/dangvanhieu2/Chapter3/issues/10"},"comments":{"href":"https://api.github.com/repos/dangvanhieu2/Chapter3/issues/10/comments"},"review_comments":{"href":"https://api.github.com/repos/dangvanhieu2/Chapter3/pulls/10/comments"},"review_comment":{"href":"https://api.github.com/repos/dangvanhieu2/Chapter3/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dangvanhieu2/Chapter3/pulls/10/commits"},"statuses":{"href":"https://api.github.com/repos/dangvanhieu2/Chapter3/statuses/09394d313f7b4421353ff3db8cc113e538a9e94e"}}}}
{"actor":{"display_login":"dangvanhieu2"}}