Created
November 9, 2010 20:30
-
-
Save a-chernykh/669746 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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