Sha256: 52d12b65e2d5b6e8f7a5eefec545c1fb2df1778d749a5ece83edeef09661c7a4

Contents?: true

Size: 517 Bytes

Versions: 11

Compression:

Stored size: 517 Bytes

Contents

# frozen_string_literal: true

# 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

11 entries across 11 versions & 1 rubygems

Version Path
solidus_auth_devise-2.5.8 config/initializers/warden.rb
solidus_auth_devise-2.5.7 config/initializers/warden.rb
solidus_auth_devise-2.5.6 config/initializers/warden.rb
solidus_auth_devise-2.5.5 config/initializers/warden.rb
solidus_auth_devise-2.5.4 config/initializers/warden.rb
solidus_auth_devise-2.5.3 config/initializers/warden.rb
solidus_auth_devise-2.5.2 config/initializers/warden.rb
solidus_auth_devise-2.5.1 config/initializers/warden.rb
solidus_auth_devise-2.5.0 config/initializers/warden.rb
solidus_auth_devise-2.4.0 config/initializers/warden.rb
solidus_auth_devise-2.3.0 config/initializers/warden.rb