From 5ed3a53f0816660aefe5d0b78245aa1ab425c9c2 Mon Sep 17 00:00:00 2001 From: yukiSasaki Date: Thu, 29 Feb 2024 02:12:14 +0900 Subject: [PATCH 1/4] =?UTF-8?q?=E8=AA=B2=E9=A1=8C=EF=BC=91=E5=AF=BE?= =?UTF-8?q?=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile.lock | 226 ++++++++++++++----------- app/controllers/sessions_controller.rb | 7 +- app/controllers/users_controller.rb | 1 + 3 files changed, 128 insertions(+), 106 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index b91808a..93c516c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,106 +1,113 @@ GEM remote: https://rubygems.org/ specs: - actioncable (7.0.4.1) - actionpack (= 7.0.4.1) - activesupport (= 7.0.4.1) + actioncable (7.0.8.1) + actionpack (= 7.0.8.1) + activesupport (= 7.0.8.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.4.1) - actionpack (= 7.0.4.1) - activejob (= 7.0.4.1) - activerecord (= 7.0.4.1) - activestorage (= 7.0.4.1) - activesupport (= 7.0.4.1) + actionmailbox (7.0.8.1) + actionpack (= 7.0.8.1) + activejob (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.4.1) - actionpack (= 7.0.4.1) - actionview (= 7.0.4.1) - activejob (= 7.0.4.1) - activesupport (= 7.0.4.1) + actionmailer (7.0.8.1) + actionpack (= 7.0.8.1) + actionview (= 7.0.8.1) + activejob (= 7.0.8.1) + activesupport (= 7.0.8.1) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.0) - actionpack (7.0.4.1) - actionview (= 7.0.4.1) - activesupport (= 7.0.4.1) - rack (~> 2.0, >= 2.2.0) + actionpack (7.0.8.1) + actionview (= 7.0.8.1) + activesupport (= 7.0.8.1) + rack (~> 2.0, >= 2.2.4) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.4.1) - actionpack (= 7.0.4.1) - activerecord (= 7.0.4.1) - activestorage (= 7.0.4.1) - activesupport (= 7.0.4.1) + actiontext (7.0.8.1) + actionpack (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.4.1) - activesupport (= 7.0.4.1) + actionview (7.0.8.1) + activesupport (= 7.0.8.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.4.1) - activesupport (= 7.0.4.1) + activejob (7.0.8.1) + activesupport (= 7.0.8.1) globalid (>= 0.3.6) - activemodel (7.0.4.1) - activesupport (= 7.0.4.1) - activerecord (7.0.4.1) - activemodel (= 7.0.4.1) - activesupport (= 7.0.4.1) - activestorage (7.0.4.1) - actionpack (= 7.0.4.1) - activejob (= 7.0.4.1) - activerecord (= 7.0.4.1) - activesupport (= 7.0.4.1) + activemodel (7.0.8.1) + activesupport (= 7.0.8.1) + activerecord (7.0.8.1) + activemodel (= 7.0.8.1) + activesupport (= 7.0.8.1) + activestorage (7.0.8.1) + actionpack (= 7.0.8.1) + activejob (= 7.0.8.1) + activerecord (= 7.0.8.1) + activesupport (= 7.0.8.1) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (7.0.4.1) + activesupport (7.0.8.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - addressable (2.8.1) + addressable (2.8.6) public_suffix (>= 2.0.2, < 6.0) - bcrypt (3.1.18) + bcrypt (3.1.20) bindex (0.8.1) - bootsnap (1.15.0) + bootsnap (1.18.3) msgpack (~> 1.2) builder (3.2.4) - capybara (3.38.0) + capybara (3.40.0) addressable matrix mini_mime (>= 0.1.3) - nokogiri (~> 1.8) + nokogiri (~> 1.11) rack (>= 1.6.0) rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) - concurrent-ruby (1.1.10) + concurrent-ruby (1.2.3) crass (1.0.6) - date (3.3.3) - debug (1.7.1) + date (3.3.4) + debug (1.9.1) + irb (~> 1.10) + reline (>= 0.3.8) erubi (1.12.0) - globalid (1.0.1) - activesupport (>= 5.0) - i18n (1.12.0) + globalid (1.2.1) + activesupport (>= 6.1) + i18n (1.14.1) concurrent-ruby (~> 1.0) - importmap-rails (1.1.5) + importmap-rails (2.0.1) actionpack (>= 6.0.0) + activesupport (>= 6.0.0) railties (>= 6.0.0) + io-console (0.7.2) + irb (1.11.2) + rdoc + reline (>= 0.4.2) jbuilder (2.11.5) actionview (>= 5.0.0) activesupport (>= 5.0.0) - loofah (2.19.1) + loofah (2.22.0) crass (~> 1.0.2) - nokogiri (>= 1.5.9) - mail (2.8.0.1) + nokogiri (>= 1.12.0) + mail (2.8.1) mini_mime (>= 0.1.1) net-imap net-pop @@ -108,99 +115,112 @@ GEM marcel (1.0.2) matrix (0.4.2) method_source (1.0.0) - mini_mime (1.1.2) - minitest (5.17.0) - msgpack (1.6.0) - net-imap (0.3.4) + mini_mime (1.1.5) + minitest (5.22.2) + msgpack (1.7.2) + net-imap (0.4.10) date net-protocol net-pop (0.1.2) net-protocol - net-protocol (0.2.1) + net-protocol (0.2.2) timeout - net-smtp (0.3.3) + net-smtp (0.4.0.1) net-protocol - nio4r (2.5.8) - nokogiri (1.14.0-aarch64-linux) + nio4r (2.7.0) + nokogiri (1.16.2-aarch64-linux) + racc (~> 1.4) + nokogiri (1.16.2-x86_64-linux) racc (~> 1.4) - public_suffix (5.0.1) - puma (5.6.5) + psych (5.1.2) + stringio + public_suffix (5.0.4) + puma (5.6.8) nio4r (~> 2.0) - racc (1.6.2) - rack (2.2.6.2) - rack-test (2.0.2) + racc (1.7.3) + rack (2.2.8.1) + rack-test (2.1.0) rack (>= 1.3) - rails (7.0.4.1) - actioncable (= 7.0.4.1) - actionmailbox (= 7.0.4.1) - actionmailer (= 7.0.4.1) - actionpack (= 7.0.4.1) - actiontext (= 7.0.4.1) - actionview (= 7.0.4.1) - activejob (= 7.0.4.1) - activemodel (= 7.0.4.1) - activerecord (= 7.0.4.1) - activestorage (= 7.0.4.1) - activesupport (= 7.0.4.1) + rails (7.0.8.1) + actioncable (= 7.0.8.1) + actionmailbox (= 7.0.8.1) + actionmailer (= 7.0.8.1) + actionpack (= 7.0.8.1) + actiontext (= 7.0.8.1) + actionview (= 7.0.8.1) + activejob (= 7.0.8.1) + activemodel (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) bundler (>= 1.15.0) - railties (= 7.0.4.1) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) + railties (= 7.0.8.1) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.5.0) - loofah (~> 2.19, >= 2.19.1) - railties (7.0.4.1) - actionpack (= 7.0.4.1) - activesupport (= 7.0.4.1) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + railties (7.0.8.1) + actionpack (= 7.0.8.1) + activesupport (= 7.0.8.1) method_source rake (>= 12.2) thor (~> 1.0) zeitwerk (~> 2.5) - rake (13.0.6) - regexp_parser (2.6.2) - rexml (3.2.5) + rake (13.1.0) + rdoc (6.6.2) + psych (>= 4.0.0) + regexp_parser (2.9.0) + reline (0.4.3) + io-console (~> 0.5) + rexml (3.2.6) rubyzip (2.3.2) - selenium-webdriver (4.7.1) + selenium-webdriver (4.10.0) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) - sprockets (4.2.0) + sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) sprockets-rails (3.4.2) actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) - sqlite3 (1.6.0-aarch64-linux) - stimulus-rails (1.2.1) + sqlite3 (1.7.2-aarch64-linux) + sqlite3 (1.7.2-x86_64-linux) + stimulus-rails (1.3.3) railties (>= 6.0.0) - thor (1.2.1) - timeout (0.3.1) - turbo-rails (1.3.2) + stringio (3.1.0) + thor (1.3.1) + timeout (0.4.1) + turbo-rails (2.0.4) actionpack (>= 6.0.0) activejob (>= 6.0.0) railties (>= 6.0.0) - tzinfo (2.0.5) + tzinfo (2.0.6) concurrent-ruby (~> 1.0) - web-console (4.2.0) + web-console (4.2.1) actionview (>= 6.0.0) activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) - webdrivers (5.2.0) + webdrivers (5.3.1) nokogiri (~> 1.6) rubyzip (>= 1.3.0) - selenium-webdriver (~> 4.0) - websocket (1.2.9) - websocket-driver (0.7.5) + selenium-webdriver (~> 4.0, < 4.11) + websocket (1.2.10) + websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.6) + zeitwerk (2.6.13) PLATFORMS aarch64-linux + x86_64-linux DEPENDENCIES bcrypt (~> 3.1.7) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 26b5e71..2ff707a 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,10 +1,11 @@ class SessionsController < ApplicationController - + protect_from_forgery def new; end def create - user = User.find_by(email: params[:email]) - if user&.authenticate(params[:password]) + user = User.find_by(email: params[:session][:email]) + + if user&.authenticate(params[:session][:password]) session[:user_id] = user.id redirect_to posts_path, notice: 'ログインしました' else diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index d3aba88..cf6e2ba 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,4 +1,5 @@ class UsersController < ApplicationController + protect_from_forgery before_action :set_user, only: %i[ show edit update destroy ] # GET /users or /users.json From cb99b89acf6bb18ccdc2aec7a5bd2da601e1bcce Mon Sep 17 00:00:00 2001 From: yukiSasaki Date: Thu, 29 Feb 2024 03:18:53 +0900 Subject: [PATCH 2/4] =?UTF-8?q?=E8=AA=B2=E9=A1=8C2=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 56fccf9..553d1cb 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,7 +1,6 @@ class ApplicationController < ActionController::Base - def current_user - @current_user ||= User.find_by(id: session[:id]) if session[:user_id].present? + @current_user ||= User.find_by(id: session[:user_id]) if session[:user_id].present? end helper_method :current_user From a5491d65bec554afd731fce7907fd712454154e2 Mon Sep 17 00:00:00 2001 From: yukiSasaki Date: Thu, 29 Feb 2024 03:34:18 +0900 Subject: [PATCH 3/4] =?UTF-8?q?=E8=AA=B2=E9=A1=8C3=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/posts/_form.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/posts/_form.html.erb b/app/views/posts/_form.html.erb index f943aad..16c95aa 100644 --- a/app/views/posts/_form.html.erb +++ b/app/views/posts/_form.html.erb @@ -13,7 +13,7 @@
<%= form.label :title, style: "display: block" %> - <%= form.text_field :titlee %> + <%= form.text_field :title %>
From da4fd17b7c9fa696826c9ac35cd3191c9aea33b4 Mon Sep 17 00:00:00 2001 From: yukiSasaki Date: Fri, 1 Mar 2024 20:19:16 +0900 Subject: [PATCH 4/4] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AA=E3=82=BD?= =?UTF-8?q?=E3=83=BC=E3=82=B9=E4=BF=AE=E6=AD=A3=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/sessions_controller.rb | 2 -- app/controllers/users_controller.rb | 1 - 2 files changed, 3 deletions(-) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 2ff707a..5ffc572 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,10 +1,8 @@ class SessionsController < ApplicationController - protect_from_forgery def new; end def create user = User.find_by(email: params[:session][:email]) - if user&.authenticate(params[:session][:password]) session[:user_id] = user.id redirect_to posts_path, notice: 'ログインしました' diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index cf6e2ba..d3aba88 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,5 +1,4 @@ class UsersController < ApplicationController - protect_from_forgery before_action :set_user, only: %i[ show edit update destroy ] # GET /users or /users.json