{"action":"created","comment":{"url":"https://api.github.com/repos/DianeRt/crud/pulls/comments/55124011","id":55124011,"diff_hunk":"@@ -46,19 +61,42 @@ def initialize\n   erb :\"users/edit\"\n end\n \n+# Login - Checks user credentials\n+#-----------------------------------------------------------------\n+post '/users/login' do\n+  @user = @users.where(username: params[:username]).first\n+  if @user == nil\n+    erb :\"homepage/error\"\n+  else\n+    # password_salt = @user[:password_salt]\n+    password = BCrypt::Engine.hash_secret(params[:password], @user[:password_salt])\n+    if @user[:password_hash] == password\n+      erb :\"users/show\"\n+    else\n+      erb :\"homepage/error\"\n+    end\n+  end\n+end\n+\n # Creates new user and saves it to database (DONE)\n #-----------------------------------------------------------------\n post '/users' do\n-  @users.insert(fname: params[:fname], lname: params[:lname], email: params[:email])\n-  redirect '/users'\n+  password_salt = BCrypt::Engine.generate_salt\n+  password_hash = BCrypt::Engine.hash_secret(params[:password], password_salt)\n+  @users.insert(fname: params[:fname], lname: params[:lname], email: params[:email], username: params[:username], password_salt: password_salt, password_hash: password_hash)\n+  @user = @users.where(username: params[:username]).first\n+  erb :\"users/show\"","path":"crud.rb","position":66,"original_position":66,"commit_id":"53ddc47ee64dc90f8af19f3f43775e346d1c922d","original_commit_id":"53ddc47ee64dc90f8af19f3f43775e346d1c922d","user":{"login":"gjaldon","id":1457730,"avatar_url":"https://avatars.githubusercontent.com/u/1457730?v=3","gravatar_id":"","url":"https://api.github.com/users/gjaldon","html_url":"https://github.com/gjaldon","followers_url":"https://api.github.com/users/gjaldon/followers","following_url":"https://api.github.com/users/gjaldon/following{/other_user}","gists_url":"https://api.github.com/users/gjaldon/gists{/gist_id}","starred_url":"https://api.github.com/users/gjaldon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gjaldon/subscriptions","organizations_url":"https://api.github.com/users/gjaldon/orgs","repos_url":"https://api.github.com/users/gjaldon/repos","events_url":"https://api.github.com/users/gjaldon/events{/privacy}","received_events_url":"https://api.github.com/users/gjaldon/received_events","type":"User","site_admin":false},"body":"Same as above, `redirect \"/users/#{id}\"`","created_at":"2016-03-05T16:55:59Z","updated_at":"2016-03-05T16:55:59Z","html_url":"https://github.com/DianeRt/crud/pull/2#discussion_r55124011","pull_request_url":"https://api.github.com/repos/DianeRt/crud/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/DianeRt/crud/pulls/comments/55124011"},"html":{"href":"https://github.com/DianeRt/crud/pull/2#discussion_r55124011"},"pull_request":{"href":"https://api.github.com/repos/DianeRt/crud/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/DianeRt/crud/pulls/2","id":61803814,"html_url":"https://github.com/DianeRt/crud/pull/2","diff_url":"https://github.com/DianeRt/crud/pull/2.diff","patch_url":"https://github.com/DianeRt/crud/pull/2.patch","issue_url":"https://api.github.com/repos/DianeRt/crud/issues/2","number":2,"state":"open","locked":false,"title":"Authentication","user":{"login":"DianeRt","id":14158917,"avatar_url":"https://avatars.githubusercontent.com/u/14158917?v=3","gravatar_id":"","url":"https://api.github.com/users/DianeRt","html_url":"https://github.com/DianeRt","followers_url":"https://api.github.com/users/DianeRt/followers","following_url":"https://api.github.com/users/DianeRt/following{/other_user}","gists_url":"https://api.github.com/users/DianeRt/gists{/gist_id}","starred_url":"https://api.github.com/users/DianeRt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DianeRt/subscriptions","organizations_url":"https://api.github.com/users/DianeRt/orgs","repos_url":"https://api.github.com/users/DianeRt/repos","events_url":"https://api.github.com/users/DianeRt/events{/privacy}","received_events_url":"https://api.github.com/users/DianeRt/received_events","type":"User","site_admin":false},"body":"used bcrypt for password and save it to database.\r\n\r\nregister works.\r\nlogin works.\r\n\r\ndid not use authlogic.","created_at":"2016-03-05T06:52:28Z","updated_at":"2016-03-05T16:55:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8058d3eb52e092a8a1f603951d68dc0c0259cc75","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/DianeRt/crud/pulls/2/commits","review_comments_url":"https://api.github.com/repos/DianeRt/crud/pulls/2/comments","review_comment_url":"https://api.github.com/repos/DianeRt/crud/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DianeRt/crud/issues/2/comments","statuses_url":"https://api.github.com/repos/DianeRt/crud/statuses/53ddc47ee64dc90f8af19f3f43775e346d1c922d","head":{"label":"DianeRt:authentication","ref":"authentication","sha":"53ddc47ee64dc90f8af19f3f43775e346d1c922d","user":{"login":"DianeRt","id":14158917,"avatar_url":"https://avatars.githubusercontent.com/u/14158917?v=3","gravatar_id":"","url":"https://api.github.com/users/DianeRt","html_url":"https://github.com/DianeRt","followers_url":"https://api.github.com/users/DianeRt/followers","following_url":"https://api.github.com/users/DianeRt/following{/other_user}","gists_url":"https://api.github.com/users/DianeRt/gists{/gist_id}","starred_url":"https://api.github.com/users/DianeRt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DianeRt/subscriptions","organizations_url":"https://api.github.com/users/DianeRt/orgs","repos_url":"https://api.github.com/users/DianeRt/repos","events_url":"https://api.github.com/users/DianeRt/events{/privacy}","received_events_url":"https://api.github.com/users/DianeRt/received_events","type":"User","site_admin":false},"repo":{"id":52657470,"name":"crud","full_name":"DianeRt/crud","owner":{"login":"DianeRt","id":14158917,"avatar_url":"https://avatars.githubusercontent.com/u/14158917?v=3","gravatar_id":"","url":"https://api.github.com/users/DianeRt","html_url":"https://github.com/DianeRt","followers_url":"https://api.github.com/users/DianeRt/followers","following_url":"https://api.github.com/users/DianeRt/following{/other_user}","gists_url":"https://api.github.com/users/DianeRt/gists{/gist_id}","starred_url":"https://api.github.com/users/DianeRt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DianeRt/subscriptions","organizations_url":"https://api.github.com/users/DianeRt/orgs","repos_url":"https://api.github.com/users/DianeRt/repos","events_url":"https://api.github.com/users/DianeRt/events{/privacy}","received_events_url":"https://api.github.com/users/DianeRt/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DianeRt/crud","description":"","fork":false,"url":"https://api.github.com/repos/DianeRt/crud","forks_url":"https://api.github.com/repos/DianeRt/crud/forks","keys_url":"https://api.github.com/repos/DianeRt/crud/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DianeRt/crud/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DianeRt/crud/teams","hooks_url":"https://api.github.com/repos/DianeRt/crud/hooks","issue_events_url":"https://api.github.com/repos/DianeRt/crud/issues/events{/number}","events_url":"https://api.github.com/repos/DianeRt/crud/events","assignees_url":"https://api.github.com/repos/DianeRt/crud/assignees{/user}","branches_url":"https://api.github.com/repos/DianeRt/crud/branches{/branch}","tags_url":"https://api.github.com/repos/DianeRt/crud/tags","blobs_url":"https://api.github.com/repos/DianeRt/crud/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DianeRt/crud/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DianeRt/crud/git/refs{/sha}","trees_url":"https://api.github.com/repos/DianeRt/crud/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DianeRt/crud/statuses/{sha}","languages_url":"https://api.github.com/repos/DianeRt/crud/languages","stargazers_url":"https://api.github.com/repos/DianeRt/crud/stargazers","contributors_url":"https://api.github.com/repos/DianeRt/crud/contributors","subscribers_url":"https://api.github.com/repos/DianeRt/crud/subscribers","subscription_url":"https://api.github.com/repos/DianeRt/crud/subscription","commits_url":"https://api.github.com/repos/DianeRt/crud/commits{/sha}","git_commits_url":"https://api.github.com/repos/DianeRt/crud/git/commits{/sha}","comments_url":"https://api.github.com/repos/DianeRt/crud/comments{/number}","issue_comment_url":"https://api.github.com/repos/DianeRt/crud/issues/comments{/number}","contents_url":"https://api.github.com/repos/DianeRt/crud/contents/{+path}","compare_url":"https://api.github.com/repos/DianeRt/crud/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DianeRt/crud/merges","archive_url":"https://api.github.com/repos/DianeRt/crud/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DianeRt/crud/downloads","issues_url":"https://api.github.com/repos/DianeRt/crud/issues{/number}","pulls_url":"https://api.github.com/repos/DianeRt/crud/pulls{/number}","milestones_url":"https://api.github.com/repos/DianeRt/crud/milestones{/number}","notifications_url":"https://api.github.com/repos/DianeRt/crud/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DianeRt/crud/labels{/name}","releases_url":"https://api.github.com/repos/DianeRt/crud/releases{/id}","deployments_url":"https://api.github.com/repos/DianeRt/crud/deployments","created_at":"2016-02-27T08:28:13Z","updated_at":"2016-02-27T08:52:44Z","pushed_at":"2016-03-05T06:52:29Z","git_url":"git://github.com/DianeRt/crud.git","ssh_url":"git@github.com:DianeRt/crud.git","clone_url":"https://github.com/DianeRt/crud.git","svn_url":"https://github.com/DianeRt/crud","homepage":null,"size":15,"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":"DianeRt:master","ref":"master","sha":"8448ed44eb1c30e4fca7d36adc7e858fb7a2959e","user":{"login":"DianeRt","id":14158917,"avatar_url":"https://avatars.githubusercontent.com/u/14158917?v=3","gravatar_id":"","url":"https://api.github.com/users/DianeRt","html_url":"https://github.com/DianeRt","followers_url":"https://api.github.com/users/DianeRt/followers","following_url":"https://api.github.com/users/DianeRt/following{/other_user}","gists_url":"https://api.github.com/users/DianeRt/gists{/gist_id}","starred_url":"https://api.github.com/users/DianeRt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DianeRt/subscriptions","organizations_url":"https://api.github.com/users/DianeRt/orgs","repos_url":"https://api.github.com/users/DianeRt/repos","events_url":"https://api.github.com/users/DianeRt/events{/privacy}","received_events_url":"https://api.github.com/users/DianeRt/received_events","type":"User","site_admin":false},"repo":{"id":52657470,"name":"crud","full_name":"DianeRt/crud","owner":{"login":"DianeRt","id":14158917,"avatar_url":"https://avatars.githubusercontent.com/u/14158917?v=3","gravatar_id":"","url":"https://api.github.com/users/DianeRt","html_url":"https://github.com/DianeRt","followers_url":"https://api.github.com/users/DianeRt/followers","following_url":"https://api.github.com/users/DianeRt/following{/other_user}","gists_url":"https://api.github.com/users/DianeRt/gists{/gist_id}","starred_url":"https://api.github.com/users/DianeRt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DianeRt/subscriptions","organizations_url":"https://api.github.com/users/DianeRt/orgs","repos_url":"https://api.github.com/users/DianeRt/repos","events_url":"https://api.github.com/users/DianeRt/events{/privacy}","received_events_url":"https://api.github.com/users/DianeRt/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DianeRt/crud","description":"","fork":false,"url":"https://api.github.com/repos/DianeRt/crud","forks_url":"https://api.github.com/repos/DianeRt/crud/forks","keys_url":"https://api.github.com/repos/DianeRt/crud/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DianeRt/crud/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DianeRt/crud/teams","hooks_url":"https://api.github.com/repos/DianeRt/crud/hooks","issue_events_url":"https://api.github.com/repos/DianeRt/crud/issues/events{/number}","events_url":"https://api.github.com/repos/DianeRt/crud/events","assignees_url":"https://api.github.com/repos/DianeRt/crud/assignees{/user}","branches_url":"https://api.github.com/repos/DianeRt/crud/branches{/branch}","tags_url":"https://api.github.com/repos/DianeRt/crud/tags","blobs_url":"https://api.github.com/repos/DianeRt/crud/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DianeRt/crud/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DianeRt/crud/git/refs{/sha}","trees_url":"https://api.github.com/repos/DianeRt/crud/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DianeRt/crud/statuses/{sha}","languages_url":"https://api.github.com/repos/DianeRt/crud/languages","stargazers_url":"https://api.github.com/repos/DianeRt/crud/stargazers","contributors_url":"https://api.github.com/repos/DianeRt/crud/contributors","subscribers_url":"https://api.github.com/repos/DianeRt/crud/subscribers","subscription_url":"https://api.github.com/repos/DianeRt/crud/subscription","commits_url":"https://api.github.com/repos/DianeRt/crud/commits{/sha}","git_commits_url":"https://api.github.com/repos/DianeRt/crud/git/commits{/sha}","comments_url":"https://api.github.com/repos/DianeRt/crud/comments{/number}","issue_comment_url":"https://api.github.com/repos/DianeRt/crud/issues/comments{/number}","contents_url":"https://api.github.com/repos/DianeRt/crud/contents/{+path}","compare_url":"https://api.github.com/repos/DianeRt/crud/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DianeRt/crud/merges","archive_url":"https://api.github.com/repos/DianeRt/crud/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DianeRt/crud/downloads","issues_url":"https://api.github.com/repos/DianeRt/crud/issues{/number}","pulls_url":"https://api.github.com/repos/DianeRt/crud/pulls{/number}","milestones_url":"https://api.github.com/repos/DianeRt/crud/milestones{/number}","notifications_url":"https://api.github.com/repos/DianeRt/crud/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DianeRt/crud/labels{/name}","releases_url":"https://api.github.com/repos/DianeRt/crud/releases{/id}","deployments_url":"https://api.github.com/repos/DianeRt/crud/deployments","created_at":"2016-02-27T08:28:13Z","updated_at":"2016-02-27T08:52:44Z","pushed_at":"2016-03-05T06:52:29Z","git_url":"git://github.com/DianeRt/crud.git","ssh_url":"git@github.com:DianeRt/crud.git","clone_url":"https://github.com/DianeRt/crud.git","svn_url":"https://github.com/DianeRt/crud","homepage":null,"size":15,"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/DianeRt/crud/pulls/2"},"html":{"href":"https://github.com/DianeRt/crud/pull/2"},"issue":{"href":"https://api.github.com/repos/DianeRt/crud/issues/2"},"comments":{"href":"https://api.github.com/repos/DianeRt/crud/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/DianeRt/crud/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/DianeRt/crud/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DianeRt/crud/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/DianeRt/crud/statuses/53ddc47ee64dc90f8af19f3f43775e346d1c922d"}}}}