Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class CustomDevise::SessionsController < Devise::SessionsController
def create
anonymous_cart = Cart.where(:security_hash => session[:security_hash]).last unless session[:security_hash].nil?
resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new")
set_flash_message :notice, :signed_in
if anonymous_cart && !anonymous_cart.user_id?
resource.cart.delete if resource.cart
anonymous_cart.update_attribute(:user_id, resource.id)
end
sign_in_and_redirect(resource_name, resource)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.