Skip to content

Commit

Permalink
Use existing return_to session param
Browse files Browse the repository at this point in the history
  • Loading branch information
adam2451 committed Mar 11, 2024
1 parent 152b2c6 commit 41c0eb5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 18 deletions.
17 changes: 2 additions & 15 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def reset_shopping # called as a filter
@gOrderInProgress.destroy if @gOrderInProgress
@gOrderInProgress = nil
set_order_in_progress(nil)
session.delete(:return_to)
session.delete(:return_to) unless (session[:return_to] != nil && session[:return_to]['action'] == 'donate') #delete session unless customer was logging in from donate page
true
end

Expand All @@ -90,15 +90,6 @@ def set_order_in_progress(order)

# Store the action to return to, or URI of the current request if no action given.
# We can return to this location by calling #redirect_after_login.
def return_to_donate_after_login()
session[:return_donate] = true
end

def redirect_to_donate_after_login(customer)
session.delete(:return_donate)
redirect_to quick_donate_path, :customer_id => customer
end

def return_after_login(route_params)
session[:return_to] = route_params
end
Expand Down Expand Up @@ -206,11 +197,7 @@ def create_session(u = nil, action = '')
if action == 'reset_token'
redirect_to change_password_for_customer_path(@user), :alert => I18n.t('login.change_password_now')
else
if session[:return_donate] == true
redirect_to_donate_after_login(@user)
else
redirect_after_login(@user)
end
redirect_after_login(@user)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/store_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ def donate_to_fund
# Serve quick_donate page; POST calls #process_donation
def donate
reset_shopping # even if order in progress, going to donation page cancels it
return_to_donate_after_login
if @customer == Customer.anonymous_customer
# handle donation as a 'guest checkout', even though may end up being tied to real customer
@customer = Customer.new
session[:guest_checkout] = true
session[:guest_checkout] = true
return_after_login params.except(:customer_id)
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/views/store/donate.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
- if session[:guest_checkout] == true
= form_tag session_path, :class => 'form' do
.row
.col-md-8
.col-md-12
.card
.card-header.text-center
%h8 Login For A Faster Checkout!
Expand Down

0 comments on commit 41c0eb5

Please sign in to comment.