solidusio / solidus_auth_devise

🔑 Devise authentication for your Solidus store.
http://solidus.io
BSD 3-Clause "New" or "Revised" License
53 stars 128 forks source link

Spree.user_class not using my specific class #169

Closed EmCousin closed 4 years ago

EmCousin commented 4 years ago

Hi,

I'm following the guidelines to set a custom auth system on my app's backend.

I have this line in my config/initializers/spree.rb file :

Spree.user_class = 'User'

but when booting the app or running the rails console, hitting Spree.user_class still returns Spree::User.

I believe this is due to this line, that is executed after loading the initializers, thus setting Spree.user_class back to Spree::User.

I've been able to workaround this issue by overriding the related initializer declaration in my main config file:

# config/application.rb
initializer "solidus_auth_devise.set_user_class", after: :load_config_initializers do
  Spree.user_class = "User"
end

Questions

Thanks in advance!

kennyadsl commented 4 years ago

Hey @EmCousin, thanks for reporting this issue. It looks a legit bug to me and I'll try to investigate further.

kennyadsl commented 4 years ago

@EmCousin can you please give a try to this PR's branch https://github.com/solidusio/solidus_auth_devise/pull/171 and let us know if this fix works?

kennyadsl commented 4 years ago

@EmCousin after a second thought, with the help of @tvdeyen, we realized that this extension is meant to be used with the Spree::User class. The possibility to change this class is left to users that do not need this extension and have a custom devise installation (or other authentication systems). Can you please provide more information about your use case?

EmCousin commented 4 years ago

Hi @kennyadsl, first, thank you for your answers.

About my use case : I plugged the solidus gem along with solidus-reviews, which requires solidus-auth-devise as a dependency, on a Rails app that already has Devise installed.

This installation is rather classic, with a database_authenticatable model User.

I'm following these guidelines to do so. It works perfectly, except for the Spree.user_class step, reason for which I initiated this issue.

Is that information relevant enough?

kennyadsl commented 4 years ago

Sure, thanks for the detailed explanation.

I think the issue here is with solidus_reviews, it should not be dependant on solidus_auth_devise.

kennyadsl commented 4 years ago

I'm having a look at that gem right now to see if we can get read of the solidus_auth_devise dependency and release a new version. I'll keep you posted.

kennyadsl commented 4 years ago

I've opened https://github.com/solidusio-contrib/solidus_reviews/pull/53 which should allow you to use the extension without solidus_auth_devise. When it will be merged, we'll release a new version of solidus_reviews that you can use.