From 9f856efe8cb979d93c94ae18899f1037457bab3b Mon Sep 17 00:00:00 2001 From: Kang-Kyu Lee Date: Fri, 9 Aug 2024 11:48:21 -0700 Subject: [PATCH 1/2] Bugfix: removing phone number from session when signup cancel --- app/controllers/phone_numbers_controller.rb | 5 +++++ app/views/users/new.html.erb | 5 ++++- config/routes.rb | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/controllers/phone_numbers_controller.rb b/app/controllers/phone_numbers_controller.rb index be7a1af..68ef771 100644 --- a/app/controllers/phone_numbers_controller.rb +++ b/app/controllers/phone_numbers_controller.rb @@ -74,6 +74,11 @@ def edit def new end + def destroy + session[:telephone] = nil + redirect_to root_url + end + private def client diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index 9790b99..7d1766b 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -1,6 +1,9 @@

Create a username


+

+ <%= button_to "Cancel", phone_numbers_delete_path, method: :delete, class: "py-2 px-4 border border-gray-500 rounded text-gray-500 hover:bg-gray-100 hover:border-gray-700 hover:text-gray-700 font-bold" %> +

<%= form_with model: @user, class: "w-full max-w-sm" do |f| %> @@ -21,7 +24,7 @@
<%= f.phone_field :phone_number, disabled: true, placeholder: "(555) 987-6543", class: "bg-gray-200 appearance-none border-2 border-gray-200 rounded w-full py-2 px-4 text-gray-700 leading-tight focus:outline-none focus:bg-white focus:border-purple-500" %>
- <%= f.submit "Verify", disabled: true, formaction: phone_numbers_verify_path, class: "relative -ml-px inline-flex items-center gap-x-1.5 rounded-r-md px-3 py-2 text-sm font-semibold text-gray-900 ring-1 ring-inset ring-gray-300 hover:bg-gray-50" %> +

verified

diff --git a/config/routes.rb b/config/routes.rb index 2c086dd..f78a757 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -8,6 +8,7 @@ post 'phone_numbers/verify' => "phone_numbers#verify" get 'phone_numbers/passcode' => "phone_numbers#edit" post 'phone_numbers/passcode' => "phone_numbers#passcode_enter" + delete 'phone_numbers/delete' => "phone_numbers#destroy" resource :session, only: [:new, :create, :destroy] get "signin" => "sessions#new" From a5ae36cbbf9bfed1b345346e30d593a961e61d88 Mon Sep 17 00:00:00 2001 From: Kang-Kyu Lee Date: Fri, 9 Aug 2024 15:46:49 -0700 Subject: [PATCH 2/2] Move cancel button in '/register' page --- app/views/users/new.html.erb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index 7d1766b..22766a0 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -1,9 +1,6 @@

Create a username


-

- <%= button_to "Cancel", phone_numbers_delete_path, method: :delete, class: "py-2 px-4 border border-gray-500 rounded text-gray-500 hover:bg-gray-100 hover:border-gray-700 hover:text-gray-700 font-bold" %> -

<%= form_with model: @user, class: "w-full max-w-sm" do |f| %> @@ -24,7 +21,7 @@
<%= f.phone_field :phone_number, disabled: true, placeholder: "(555) 987-6543", class: "bg-gray-200 appearance-none border-2 border-gray-200 rounded w-full py-2 px-4 text-gray-700 leading-tight focus:outline-none focus:bg-white focus:border-purple-500" %>
-

verified

+

@@ -43,3 +40,9 @@ <% end %> + +
+ +
+ <%= button_to "Cancel", phone_numbers_delete_path, method: :delete, class: "py-2 px-4 border border-gray-500 rounded text-gray-500 hover:bg-gray-100 hover:border-gray-700 hover:text-gray-700 font-bold" %> +