{"action":"created","comment":{"url":"https://api.github.com/repos/openstax/accounts/pulls/comments/23737738","id":23737738,"diff_hunk":"@@ -23,68 +24,38 @@ def authenticate unencrypted_password\n     end\n   end\n \n-  # Generates a reset code (and saves the identity without validation)\n-  def generate_reset_code!(expiration_period=DEFAULT_RESET_CODE_EXPIRATION_PERIOD)\n-    self.reset_code = SecureRandom.hex(16)\n-    if !expiration_period.nil?\n-      self.reset_code_expires_at = DateTime.now + expiration_period\n-    else\n-      self.reset_code_expires_at = nil\n-    end\n-    self.save!(validate: false)\n-    self.reset_code\n+  # Returns true if the user is due for resetting their password\n+  def password_expired?\n+    !password_expires_at.nil? && password_expires_at <= DateTime.now\n   end\n \n-  # Returns true iff the code is valid and matches\n-  def reset_code_valid?(code)\n-    return true if self.reset_code == code && \\\n-                     (self.reset_code_expires_at.nil? || \\\n-                     self.reset_code_expires_at >= DateTime.now)\n-    false\n-  end\n-\n-  # Sets the password (and saves the identity)\n-  def set_password!(password, password_confirmation)\n-    # Always invalidate reset codes when the password changes\n-    self.reset_code = nil\n-    self.reset_code_expires_at = nil\n-\n+  # Sets the password and the password expiration date; Returns nil\n+  def set_password(password,\n+                   password_confirmation = nil,\n+                   expiration_period = DEFAULT_PASSWORD_EXPIRATION_PERIOD)","path":"app/models/identity.rb","position":69,"original_position":69,"commit_id":"c0e7d7a6e1eab4b9e9afa8a5c2538bf09b5f4b12","original_commit_id":"c0e7d7a6e1eab4b9e9afa8a5c2538bf09b5f4b12","user":{"login":"jpslav","id":1001691,"avatar_url":"https://avatars.githubusercontent.com/u/1001691?v=3","gravatar_id":"","url":"https://api.github.com/users/jpslav","html_url":"https://github.com/jpslav","followers_url":"https://api.github.com/users/jpslav/followers","following_url":"https://api.github.com/users/jpslav/following{/other_user}","gists_url":"https://api.github.com/users/jpslav/gists{/gist_id}","starred_url":"https://api.github.com/users/jpslav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpslav/subscriptions","organizations_url":"https://api.github.com/users/jpslav/orgs","repos_url":"https://api.github.com/users/jpslav/repos","events_url":"https://api.github.com/users/jpslav/events{/privacy}","received_events_url":"https://api.github.com/users/jpslav/received_events","type":"User","site_admin":false},"body":"nvm, confusing Github diff coloring.","created_at":"2015-01-29T00:29:39Z","updated_at":"2015-01-29T00:29:39Z","html_url":"https://github.com/openstax/accounts/pull/118#discussion_r23737738","pull_request_url":"https://api.github.com/repos/openstax/accounts/pulls/118","_links":{"self":{"href":"https://api.github.com/repos/openstax/accounts/pulls/comments/23737738"},"html":{"href":"https://github.com/openstax/accounts/pull/118#discussion_r23737738"},"pull_request":{"href":"https://api.github.com/repos/openstax/accounts/pulls/118"}}},"pull_request":{"url":"https://api.github.com/repos/openstax/accounts/pulls/118","id":28239440,"html_url":"https://github.com/openstax/accounts/pull/118","diff_url":"https://github.com/openstax/accounts/pull/118.diff","patch_url":"https://github.com/openstax/accounts/pull/118.patch","issue_url":"https://api.github.com/repos/openstax/accounts/issues/118","number":118,"state":"open","locked":false,"title":"Authentication fix plus identity refactoring","user":{"login":"Dantemss","id":1017808,"avatar_url":"https://avatars.githubusercontent.com/u/1017808?v=3","gravatar_id":"","url":"https://api.github.com/users/Dantemss","html_url":"https://github.com/Dantemss","followers_url":"https://api.github.com/users/Dantemss/followers","following_url":"https://api.github.com/users/Dantemss/following{/other_user}","gists_url":"https://api.github.com/users/Dantemss/gists{/gist_id}","starred_url":"https://api.github.com/users/Dantemss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dantemss/subscriptions","organizations_url":"https://api.github.com/users/Dantemss/orgs","repos_url":"https://api.github.com/users/Dantemss/repos","events_url":"https://api.github.com/users/Dantemss/events{/privacy}","received_events_url":"https://api.github.com/users/Dantemss/received_events","type":"User","site_admin":false},"body":"I might have gotten a bit carried away with the refactoring... but hopefully for the best?\r\n\r\nWe should refactor the SessionsCallback eventually. It's honestly still too complex.","created_at":"2015-01-28T23:17:03Z","updated_at":"2015-01-29T00:29:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b0f733c60a121089d90f4bc148818fd2eff1e33f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/openstax/accounts/pulls/118/commits","review_comments_url":"https://api.github.com/repos/openstax/accounts/pulls/118/comments","review_comment_url":"https://api.github.com/repos/openstax/accounts/pulls/comments/{number}","comments_url":"https://api.github.com/repos/openstax/accounts/issues/118/comments","statuses_url":"https://api.github.com/repos/openstax/accounts/statuses/c0e7d7a6e1eab4b9e9afa8a5c2538bf09b5f4b12","head":{"label":"Dantemss:master","ref":"master","sha":"c0e7d7a6e1eab4b9e9afa8a5c2538bf09b5f4b12","user":{"login":"Dantemss","id":1017808,"avatar_url":"https://avatars.githubusercontent.com/u/1017808?v=3","gravatar_id":"","url":"https://api.github.com/users/Dantemss","html_url":"https://github.com/Dantemss","followers_url":"https://api.github.com/users/Dantemss/followers","following_url":"https://api.github.com/users/Dantemss/following{/other_user}","gists_url":"https://api.github.com/users/Dantemss/gists{/gist_id}","starred_url":"https://api.github.com/users/Dantemss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dantemss/subscriptions","organizations_url":"https://api.github.com/users/Dantemss/orgs","repos_url":"https://api.github.com/users/Dantemss/repos","events_url":"https://api.github.com/users/Dantemss/events{/privacy}","received_events_url":"https://api.github.com/users/Dantemss/received_events","type":"User","site_admin":false},"repo":{"id":17497595,"name":"accounts","full_name":"Dantemss/accounts","owner":{"login":"Dantemss","id":1017808,"avatar_url":"https://avatars.githubusercontent.com/u/1017808?v=3","gravatar_id":"","url":"https://api.github.com/users/Dantemss","html_url":"https://github.com/Dantemss","followers_url":"https://api.github.com/users/Dantemss/followers","following_url":"https://api.github.com/users/Dantemss/following{/other_user}","gists_url":"https://api.github.com/users/Dantemss/gists{/gist_id}","starred_url":"https://api.github.com/users/Dantemss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dantemss/subscriptions","organizations_url":"https://api.github.com/users/Dantemss/orgs","repos_url":"https://api.github.com/users/Dantemss/repos","events_url":"https://api.github.com/users/Dantemss/events{/privacy}","received_events_url":"https://api.github.com/users/Dantemss/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Dantemss/accounts","description":"OpenStax common services API server","fork":true,"url":"https://api.github.com/repos/Dantemss/accounts","forks_url":"https://api.github.com/repos/Dantemss/accounts/forks","keys_url":"https://api.github.com/repos/Dantemss/accounts/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Dantemss/accounts/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Dantemss/accounts/teams","hooks_url":"https://api.github.com/repos/Dantemss/accounts/hooks","issue_events_url":"https://api.github.com/repos/Dantemss/accounts/issues/events{/number}","events_url":"https://api.github.com/repos/Dantemss/accounts/events","assignees_url":"https://api.github.com/repos/Dantemss/accounts/assignees{/user}","branches_url":"https://api.github.com/repos/Dantemss/accounts/branches{/branch}","tags_url":"https://api.github.com/repos/Dantemss/accounts/tags","blobs_url":"https://api.github.com/repos/Dantemss/accounts/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Dantemss/accounts/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Dantemss/accounts/git/refs{/sha}","trees_url":"https://api.github.com/repos/Dantemss/accounts/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Dantemss/accounts/statuses/{sha}","languages_url":"https://api.github.com/repos/Dantemss/accounts/languages","stargazers_url":"https://api.github.com/repos/Dantemss/accounts/stargazers","contributors_url":"https://api.github.com/repos/Dantemss/accounts/contributors","subscribers_url":"https://api.github.com/repos/Dantemss/accounts/subscribers","subscription_url":"https://api.github.com/repos/Dantemss/accounts/subscription","commits_url":"https://api.github.com/repos/Dantemss/accounts/commits{/sha}","git_commits_url":"https://api.github.com/repos/Dantemss/accounts/git/commits{/sha}","comments_url":"https://api.github.com/repos/Dantemss/accounts/comments{/number}","issue_comment_url":"https://api.github.com/repos/Dantemss/accounts/issues/comments/{number}","contents_url":"https://api.github.com/repos/Dantemss/accounts/contents/{+path}","compare_url":"https://api.github.com/repos/Dantemss/accounts/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Dantemss/accounts/merges","archive_url":"https://api.github.com/repos/Dantemss/accounts/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Dantemss/accounts/downloads","issues_url":"https://api.github.com/repos/Dantemss/accounts/issues{/number}","pulls_url":"https://api.github.com/repos/Dantemss/accounts/pulls{/number}","milestones_url":"https://api.github.com/repos/Dantemss/accounts/milestones{/number}","notifications_url":"https://api.github.com/repos/Dantemss/accounts/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Dantemss/accounts/labels{/name}","releases_url":"https://api.github.com/repos/Dantemss/accounts/releases{/id}","created_at":"2014-03-07T00:26:31Z","updated_at":"2015-01-28T23:53:05Z","pushed_at":"2015-01-28T23:53:05Z","git_url":"git://github.com/Dantemss/accounts.git","ssh_url":"git@github.com:Dantemss/accounts.git","clone_url":"https://github.com/Dantemss/accounts.git","svn_url":"https://github.com/Dantemss/accounts","homepage":null,"size":1500,"stargazers_count":0,"watchers_count":0,"language":"Ruby","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":"openstax:master","ref":"master","sha":"98cb870789d1bf9ba9af98c76ea4a9812ef1d734","user":{"login":"openstax","id":3805549,"avatar_url":"https://avatars.githubusercontent.com/u/3805549?v=3","gravatar_id":"","url":"https://api.github.com/users/openstax","html_url":"https://github.com/openstax","followers_url":"https://api.github.com/users/openstax/followers","following_url":"https://api.github.com/users/openstax/following{/other_user}","gists_url":"https://api.github.com/users/openstax/gists{/gist_id}","starred_url":"https://api.github.com/users/openstax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openstax/subscriptions","organizations_url":"https://api.github.com/users/openstax/orgs","repos_url":"https://api.github.com/users/openstax/repos","events_url":"https://api.github.com/users/openstax/events{/privacy}","received_events_url":"https://api.github.com/users/openstax/received_events","type":"Organization","site_admin":false},"repo":{"id":11300066,"name":"accounts","full_name":"openstax/accounts","owner":{"login":"openstax","id":3805549,"avatar_url":"https://avatars.githubusercontent.com/u/3805549?v=3","gravatar_id":"","url":"https://api.github.com/users/openstax","html_url":"https://github.com/openstax","followers_url":"https://api.github.com/users/openstax/followers","following_url":"https://api.github.com/users/openstax/following{/other_user}","gists_url":"https://api.github.com/users/openstax/gists{/gist_id}","starred_url":"https://api.github.com/users/openstax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openstax/subscriptions","organizations_url":"https://api.github.com/users/openstax/orgs","repos_url":"https://api.github.com/users/openstax/repos","events_url":"https://api.github.com/users/openstax/events{/privacy}","received_events_url":"https://api.github.com/users/openstax/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openstax/accounts","description":"OpenStax centralized authentication and accounts service","fork":false,"url":"https://api.github.com/repos/openstax/accounts","forks_url":"https://api.github.com/repos/openstax/accounts/forks","keys_url":"https://api.github.com/repos/openstax/accounts/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openstax/accounts/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openstax/accounts/teams","hooks_url":"https://api.github.com/repos/openstax/accounts/hooks","issue_events_url":"https://api.github.com/repos/openstax/accounts/issues/events{/number}","events_url":"https://api.github.com/repos/openstax/accounts/events","assignees_url":"https://api.github.com/repos/openstax/accounts/assignees{/user}","branches_url":"https://api.github.com/repos/openstax/accounts/branches{/branch}","tags_url":"https://api.github.com/repos/openstax/accounts/tags","blobs_url":"https://api.github.com/repos/openstax/accounts/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openstax/accounts/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openstax/accounts/git/refs{/sha}","trees_url":"https://api.github.com/repos/openstax/accounts/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openstax/accounts/statuses/{sha}","languages_url":"https://api.github.com/repos/openstax/accounts/languages","stargazers_url":"https://api.github.com/repos/openstax/accounts/stargazers","contributors_url":"https://api.github.com/repos/openstax/accounts/contributors","subscribers_url":"https://api.github.com/repos/openstax/accounts/subscribers","subscription_url":"https://api.github.com/repos/openstax/accounts/subscription","commits_url":"https://api.github.com/repos/openstax/accounts/commits{/sha}","git_commits_url":"https://api.github.com/repos/openstax/accounts/git/commits{/sha}","comments_url":"https://api.github.com/repos/openstax/accounts/comments{/number}","issue_comment_url":"https://api.github.com/repos/openstax/accounts/issues/comments/{number}","contents_url":"https://api.github.com/repos/openstax/accounts/contents/{+path}","compare_url":"https://api.github.com/repos/openstax/accounts/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openstax/accounts/merges","archive_url":"https://api.github.com/repos/openstax/accounts/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openstax/accounts/downloads","issues_url":"https://api.github.com/repos/openstax/accounts/issues{/number}","pulls_url":"https://api.github.com/repos/openstax/accounts/pulls{/number}","milestones_url":"https://api.github.com/repos/openstax/accounts/milestones{/number}","notifications_url":"https://api.github.com/repos/openstax/accounts/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openstax/accounts/labels{/name}","releases_url":"https://api.github.com/repos/openstax/accounts/releases{/id}","created_at":"2013-07-10T02:36:07Z","updated_at":"2015-01-27T17:19:34Z","pushed_at":"2015-01-27T17:19:33Z","git_url":"git://github.com/openstax/accounts.git","ssh_url":"git@github.com:openstax/accounts.git","clone_url":"https://github.com/openstax/accounts.git","svn_url":"https://github.com/openstax/accounts","homepage":"","size":1527,"stargazers_count":2,"watchers_count":2,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":14,"forks":5,"open_issues":14,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openstax/accounts/pulls/118"},"html":{"href":"https://github.com/openstax/accounts/pull/118"},"issue":{"href":"https://api.github.com/repos/openstax/accounts/issues/118"},"comments":{"href":"https://api.github.com/repos/openstax/accounts/issues/118/comments"},"review_comments":{"href":"https://api.github.com/repos/openstax/accounts/pulls/118/comments"},"review_comment":{"href":"https://api.github.com/repos/openstax/accounts/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/openstax/accounts/pulls/118/commits"},"statuses":{"href":"https://api.github.com/repos/openstax/accounts/statuses/c0e7d7a6e1eab4b9e9afa8a5c2538bf09b5f4b12"}}}}