{"action":"created","comment":{"url":"https://api.github.com/repos/muaddeep/cars_test/pulls/comments/47757264","id":47757264,"diff_hunk":"@@ -0,0 +1,83 @@\n+class User < ActiveRecord::Base\n+  validates :email, uniqueness: {case_sensitive: false}, presence: true, length: {maximum: 256}\n+  validate :changing_to_not_existing_email\n+\n+  has_secure_password\n+\n+  before_create :add_validation_token\n+\n+  def User.new_validation_token\n+    SecureRandom.urlsafe_base64\n+  end\n+\n+\n+  def update_settings(new_params)\n+    if self.email != new_params[:email]\n+      set_change_email_token new_params[:email]\n+    else\n+      self.update new_params\n+    end\n+\n+    return self\n+  end\n+\n+  def User.change_email(token)\n+    user = User.where(validation_token: token).where('validation_token_expire > ?', DateTime.now).first\n+    if user\n+      user.email = user.email_to_change\n+      user.email_to_change = nil\n+      user.validation_token = nil\n+      user.validation_token_expire = nil\n+      user.save\n+    else\n+      user = nil\n+    end\n+    return user\n+  end\n+\n+  def User.activate_user(token)\n+    user = User.where(validation_token: token).where('validation_token_expire > ?', DateTime.now).first\n+    if user\n+      user.active = true\n+      user.validation_token = nil\n+      user.validation_token_expire = nil\n+      user.save\n+    else\n+      user = nil\n+    end\n+    return user\n+  end\n+\n+  #TODO: remove this one, it used just for tests now\n+  def set_validation_token\n+    add_validation_token\n+    self.save\n+  end\n+\n+  private\n+\n+  def set_change_email_token(new_email)\n+    add_validation_token\n+    self.email_to_change = new_email","path":"app/models/user.rb","position":61,"original_position":61,"commit_id":"032d0b5e8d19180210b2a0d8147ce3046097cd3d","original_commit_id":"032d0b5e8d19180210b2a0d8147ce3046097cd3d","user":{"login":"muaddeep","id":539381,"avatar_url":"https://avatars.githubusercontent.com/u/539381?v=3","gravatar_id":"","url":"https://api.github.com/users/muaddeep","html_url":"https://github.com/muaddeep","followers_url":"https://api.github.com/users/muaddeep/followers","following_url":"https://api.github.com/users/muaddeep/following{/other_user}","gists_url":"https://api.github.com/users/muaddeep/gists{/gist_id}","starred_url":"https://api.github.com/users/muaddeep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muaddeep/subscriptions","organizations_url":"https://api.github.com/users/muaddeep/orgs","repos_url":"https://api.github.com/users/muaddeep/repos","events_url":"https://api.github.com/users/muaddeep/events{/privacy}","received_events_url":"https://api.github.com/users/muaddeep/received_events","type":"User","site_admin":false},"body":"Не, я бы понял вопрос почему это хранится таким образом (т.e. в таблице  users), хотя для игрушечной аутентификации это как-то пофигу. Но зачем хранить email на который мы хотим сменить текущий отдельно, до того как изменение были подтверждены... это какой-то очень странный вопрос. Посмотри чтоли код devise, который ты рекомендуешь, или попробуй сам написать это же: узнаешь для себя много нового.\r\n\r\nИ таки да, пароль, который тоже можно сменить, таким образом не обрабатывается.","created_at":"2015-12-16T10:09:17Z","updated_at":"2015-12-16T10:09:17Z","html_url":"https://github.com/muaddeep/cars_test/pull/1#discussion_r47757264","pull_request_url":"https://api.github.com/repos/muaddeep/cars_test/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/muaddeep/cars_test/pulls/comments/47757264"},"html":{"href":"https://github.com/muaddeep/cars_test/pull/1#discussion_r47757264"},"pull_request":{"href":"https://api.github.com/repos/muaddeep/cars_test/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/muaddeep/cars_test/pulls/1","id":53515718,"html_url":"https://github.com/muaddeep/cars_test/pull/1","diff_url":"https://github.com/muaddeep/cars_test/pull/1.diff","patch_url":"https://github.com/muaddeep/cars_test/pull/1.patch","issue_url":"https://api.github.com/repos/muaddeep/cars_test/issues/1","number":1,"state":"open","locked":false,"title":"Experimental","user":{"login":"muaddeep","id":539381,"avatar_url":"https://avatars.githubusercontent.com/u/539381?v=3","gravatar_id":"","url":"https://api.github.com/users/muaddeep","html_url":"https://github.com/muaddeep","followers_url":"https://api.github.com/users/muaddeep/followers","following_url":"https://api.github.com/users/muaddeep/following{/other_user}","gists_url":"https://api.github.com/users/muaddeep/gists{/gist_id}","starred_url":"https://api.github.com/users/muaddeep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muaddeep/subscriptions","organizations_url":"https://api.github.com/users/muaddeep/orgs","repos_url":"https://api.github.com/users/muaddeep/repos","events_url":"https://api.github.com/users/muaddeep/events{/privacy}","received_events_url":"https://api.github.com/users/muaddeep/received_events","type":"User","site_admin":false},"body":"first part","created_at":"2015-12-14T01:01:22Z","updated_at":"2015-12-16T10:09:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7b817c5205010ab764c3ef4dcc8eee2318ad919d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/muaddeep/cars_test/pulls/1/commits","review_comments_url":"https://api.github.com/repos/muaddeep/cars_test/pulls/1/comments","review_comment_url":"https://api.github.com/repos/muaddeep/cars_test/pulls/comments{/number}","comments_url":"https://api.github.com/repos/muaddeep/cars_test/issues/1/comments","statuses_url":"https://api.github.com/repos/muaddeep/cars_test/statuses/032d0b5e8d19180210b2a0d8147ce3046097cd3d","head":{"label":"muaddeep:experimental","ref":"experimental","sha":"032d0b5e8d19180210b2a0d8147ce3046097cd3d","user":{"login":"muaddeep","id":539381,"avatar_url":"https://avatars.githubusercontent.com/u/539381?v=3","gravatar_id":"","url":"https://api.github.com/users/muaddeep","html_url":"https://github.com/muaddeep","followers_url":"https://api.github.com/users/muaddeep/followers","following_url":"https://api.github.com/users/muaddeep/following{/other_user}","gists_url":"https://api.github.com/users/muaddeep/gists{/gist_id}","starred_url":"https://api.github.com/users/muaddeep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muaddeep/subscriptions","organizations_url":"https://api.github.com/users/muaddeep/orgs","repos_url":"https://api.github.com/users/muaddeep/repos","events_url":"https://api.github.com/users/muaddeep/events{/privacy}","received_events_url":"https://api.github.com/users/muaddeep/received_events","type":"User","site_admin":false},"repo":{"id":47944020,"name":"cars_test","full_name":"muaddeep/cars_test","owner":{"login":"muaddeep","id":539381,"avatar_url":"https://avatars.githubusercontent.com/u/539381?v=3","gravatar_id":"","url":"https://api.github.com/users/muaddeep","html_url":"https://github.com/muaddeep","followers_url":"https://api.github.com/users/muaddeep/followers","following_url":"https://api.github.com/users/muaddeep/following{/other_user}","gists_url":"https://api.github.com/users/muaddeep/gists{/gist_id}","starred_url":"https://api.github.com/users/muaddeep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muaddeep/subscriptions","organizations_url":"https://api.github.com/users/muaddeep/orgs","repos_url":"https://api.github.com/users/muaddeep/repos","events_url":"https://api.github.com/users/muaddeep/events{/privacy}","received_events_url":"https://api.github.com/users/muaddeep/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/muaddeep/cars_test","description":"playing with rails","fork":false,"url":"https://api.github.com/repos/muaddeep/cars_test","forks_url":"https://api.github.com/repos/muaddeep/cars_test/forks","keys_url":"https://api.github.com/repos/muaddeep/cars_test/keys{/key_id}","collaborators_url":"https://api.github.com/repos/muaddeep/cars_test/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/muaddeep/cars_test/teams","hooks_url":"https://api.github.com/repos/muaddeep/cars_test/hooks","issue_events_url":"https://api.github.com/repos/muaddeep/cars_test/issues/events{/number}","events_url":"https://api.github.com/repos/muaddeep/cars_test/events","assignees_url":"https://api.github.com/repos/muaddeep/cars_test/assignees{/user}","branches_url":"https://api.github.com/repos/muaddeep/cars_test/branches{/branch}","tags_url":"https://api.github.com/repos/muaddeep/cars_test/tags","blobs_url":"https://api.github.com/repos/muaddeep/cars_test/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/muaddeep/cars_test/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/muaddeep/cars_test/git/refs{/sha}","trees_url":"https://api.github.com/repos/muaddeep/cars_test/git/trees{/sha}","statuses_url":"https://api.github.com/repos/muaddeep/cars_test/statuses/{sha}","languages_url":"https://api.github.com/repos/muaddeep/cars_test/languages","stargazers_url":"https://api.github.com/repos/muaddeep/cars_test/stargazers","contributors_url":"https://api.github.com/repos/muaddeep/cars_test/contributors","subscribers_url":"https://api.github.com/repos/muaddeep/cars_test/subscribers","subscription_url":"https://api.github.com/repos/muaddeep/cars_test/subscription","commits_url":"https://api.github.com/repos/muaddeep/cars_test/commits{/sha}","git_commits_url":"https://api.github.com/repos/muaddeep/cars_test/git/commits{/sha}","comments_url":"https://api.github.com/repos/muaddeep/cars_test/comments{/number}","issue_comment_url":"https://api.github.com/repos/muaddeep/cars_test/issues/comments{/number}","contents_url":"https://api.github.com/repos/muaddeep/cars_test/contents/{+path}","compare_url":"https://api.github.com/repos/muaddeep/cars_test/compare/{base}...{head}","merges_url":"https://api.github.com/repos/muaddeep/cars_test/merges","archive_url":"https://api.github.com/repos/muaddeep/cars_test/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/muaddeep/cars_test/downloads","issues_url":"https://api.github.com/repos/muaddeep/cars_test/issues{/number}","pulls_url":"https://api.github.com/repos/muaddeep/cars_test/pulls{/number}","milestones_url":"https://api.github.com/repos/muaddeep/cars_test/milestones{/number}","notifications_url":"https://api.github.com/repos/muaddeep/cars_test/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/muaddeep/cars_test/labels{/name}","releases_url":"https://api.github.com/repos/muaddeep/cars_test/releases{/id}","created_at":"2015-12-14T00:55:45Z","updated_at":"2015-12-14T00:56:33Z","pushed_at":"2015-12-14T14:01:41Z","git_url":"git://github.com/muaddeep/cars_test.git","ssh_url":"git@github.com:muaddeep/cars_test.git","clone_url":"https://github.com/muaddeep/cars_test.git","svn_url":"https://github.com/muaddeep/cars_test","homepage":null,"size":69,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":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":"muaddeep:master","ref":"master","sha":"53110bda198525cc8ae05684413e7f97c729a24f","user":{"login":"muaddeep","id":539381,"avatar_url":"https://avatars.githubusercontent.com/u/539381?v=3","gravatar_id":"","url":"https://api.github.com/users/muaddeep","html_url":"https://github.com/muaddeep","followers_url":"https://api.github.com/users/muaddeep/followers","following_url":"https://api.github.com/users/muaddeep/following{/other_user}","gists_url":"https://api.github.com/users/muaddeep/gists{/gist_id}","starred_url":"https://api.github.com/users/muaddeep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muaddeep/subscriptions","organizations_url":"https://api.github.com/users/muaddeep/orgs","repos_url":"https://api.github.com/users/muaddeep/repos","events_url":"https://api.github.com/users/muaddeep/events{/privacy}","received_events_url":"https://api.github.com/users/muaddeep/received_events","type":"User","site_admin":false},"repo":{"id":47944020,"name":"cars_test","full_name":"muaddeep/cars_test","owner":{"login":"muaddeep","id":539381,"avatar_url":"https://avatars.githubusercontent.com/u/539381?v=3","gravatar_id":"","url":"https://api.github.com/users/muaddeep","html_url":"https://github.com/muaddeep","followers_url":"https://api.github.com/users/muaddeep/followers","following_url":"https://api.github.com/users/muaddeep/following{/other_user}","gists_url":"https://api.github.com/users/muaddeep/gists{/gist_id}","starred_url":"https://api.github.com/users/muaddeep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muaddeep/subscriptions","organizations_url":"https://api.github.com/users/muaddeep/orgs","repos_url":"https://api.github.com/users/muaddeep/repos","events_url":"https://api.github.com/users/muaddeep/events{/privacy}","received_events_url":"https://api.github.com/users/muaddeep/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/muaddeep/cars_test","description":"playing with rails","fork":false,"url":"https://api.github.com/repos/muaddeep/cars_test","forks_url":"https://api.github.com/repos/muaddeep/cars_test/forks","keys_url":"https://api.github.com/repos/muaddeep/cars_test/keys{/key_id}","collaborators_url":"https://api.github.com/repos/muaddeep/cars_test/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/muaddeep/cars_test/teams","hooks_url":"https://api.github.com/repos/muaddeep/cars_test/hooks","issue_events_url":"https://api.github.com/repos/muaddeep/cars_test/issues/events{/number}","events_url":"https://api.github.com/repos/muaddeep/cars_test/events","assignees_url":"https://api.github.com/repos/muaddeep/cars_test/assignees{/user}","branches_url":"https://api.github.com/repos/muaddeep/cars_test/branches{/branch}","tags_url":"https://api.github.com/repos/muaddeep/cars_test/tags","blobs_url":"https://api.github.com/repos/muaddeep/cars_test/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/muaddeep/cars_test/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/muaddeep/cars_test/git/refs{/sha}","trees_url":"https://api.github.com/repos/muaddeep/cars_test/git/trees{/sha}","statuses_url":"https://api.github.com/repos/muaddeep/cars_test/statuses/{sha}","languages_url":"https://api.github.com/repos/muaddeep/cars_test/languages","stargazers_url":"https://api.github.com/repos/muaddeep/cars_test/stargazers","contributors_url":"https://api.github.com/repos/muaddeep/cars_test/contributors","subscribers_url":"https://api.github.com/repos/muaddeep/cars_test/subscribers","subscription_url":"https://api.github.com/repos/muaddeep/cars_test/subscription","commits_url":"https://api.github.com/repos/muaddeep/cars_test/commits{/sha}","git_commits_url":"https://api.github.com/repos/muaddeep/cars_test/git/commits{/sha}","comments_url":"https://api.github.com/repos/muaddeep/cars_test/comments{/number}","issue_comment_url":"https://api.github.com/repos/muaddeep/cars_test/issues/comments{/number}","contents_url":"https://api.github.com/repos/muaddeep/cars_test/contents/{+path}","compare_url":"https://api.github.com/repos/muaddeep/cars_test/compare/{base}...{head}","merges_url":"https://api.github.com/repos/muaddeep/cars_test/merges","archive_url":"https://api.github.com/repos/muaddeep/cars_test/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/muaddeep/cars_test/downloads","issues_url":"https://api.github.com/repos/muaddeep/cars_test/issues{/number}","pulls_url":"https://api.github.com/repos/muaddeep/cars_test/pulls{/number}","milestones_url":"https://api.github.com/repos/muaddeep/cars_test/milestones{/number}","notifications_url":"https://api.github.com/repos/muaddeep/cars_test/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/muaddeep/cars_test/labels{/name}","releases_url":"https://api.github.com/repos/muaddeep/cars_test/releases{/id}","created_at":"2015-12-14T00:55:45Z","updated_at":"2015-12-14T00:56:33Z","pushed_at":"2015-12-14T14:01:41Z","git_url":"git://github.com/muaddeep/cars_test.git","ssh_url":"git@github.com:muaddeep/cars_test.git","clone_url":"https://github.com/muaddeep/cars_test.git","svn_url":"https://github.com/muaddeep/cars_test","homepage":null,"size":69,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":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/muaddeep/cars_test/pulls/1"},"html":{"href":"https://github.com/muaddeep/cars_test/pull/1"},"issue":{"href":"https://api.github.com/repos/muaddeep/cars_test/issues/1"},"comments":{"href":"https://api.github.com/repos/muaddeep/cars_test/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/muaddeep/cars_test/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/muaddeep/cars_test/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/muaddeep/cars_test/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/muaddeep/cars_test/statuses/032d0b5e8d19180210b2a0d8147ce3046097cd3d"}}}}