Sha256: 8740e9f87a0c4a6abc5014a683dfb721b97e14b19c2e261f7dd5c4352e144608

Contents?: true

Size: 483 Bytes

Versions: 17

Compression:

Stored size: 483 Bytes

Contents

# Merges users orders to their account after sign in and sign up.
Warden::Manager.after_set_user except: :fetch do |user, auth, opts|
  if auth.cookies.signed[:guest_token].present?
    if user.is_a?(Spree::User)
      Spree::Order.incomplete.where(guest_token: auth.cookies.signed[:guest_token], user_id: nil).each do |order|
        order.associate_user!(user)
      end
    end
  end
end

Warden::Manager.before_logout do |user, auth, opts|
  auth.cookies.delete :guest_token
end

Version data entries

17 entries across 17 versions & 3 rubygems

Version Path
solidus_auth_devise-2.2.0 config/initializers/warden.rb
solidus_auth_devise_devise_token_auth-2.1.0.5 config/initializers/warden.rb
solidus_auth_devise_devise_token_auth-2.1.0.4 config/initializers/warden.rb
solidus_auth_devise_devise_token_auth-2.1.0.3 config/initializers/warden.rb
solidus_auth_devise_devise_token_auth-2.1.0.2 config/initializers/warden.rb
solidus_auth_devise_devise_token_auth-2.1.0.1 config/initializers/warden.rb
solidus_auth_devise_devise_token_auth-2.1.0 config/initializers/warden.rb
solidus_auth_devise-2.1.0 config/initializers/warden.rb
solidus_auth_devise-2.0.0 config/initializers/warden.rb
solidus_auth_devise-1.6.4 config/initializers/warden.rb
solidus_auth_devise-1.6.3 config/initializers/warden.rb
spree_auth_devise-3.2.0.beta config/initializers/warden.rb
solidus_auth_devise-1.6.2 config/initializers/warden.rb
solidus_auth_devise-1.6.1 config/initializers/warden.rb
solidus_auth_devise-1.6.0 config/initializers/warden.rb
solidus_auth_devise-1.5.0 config/initializers/warden.rb
solidus_auth_devise-1.4.0 config/initializers/warden.rb