Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spree.user_class not using my specific class #169

Closed
EmCousin opened this issue Aug 30, 2019 · 7 comments · Fixed by solidusio-contrib/solidus_reviews#53
Closed

Spree.user_class not using my specific class #169

EmCousin opened this issue Aug 30, 2019 · 7 comments · Fixed by solidusio-contrib/solidus_reviews#53

Comments

@EmCousin
Copy link

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

  • Did I have the wrong interpretation and I could have messed something up in my app?
  • Otherwise, should the custom generator instead generate the block I wrote above?

Thanks in advance!

@kennyadsl
Copy link
Member

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

kennyadsl added a commit to nebulab/solidus_auth_devise that referenced this issue Sep 16, 2019
Currently, when this class is set with a custom value using an
initializer in the host application, it is not having any effect
because this line is always overwriting the custom value with the
default one.

Ref: solidusio#169
@kennyadsl
Copy link
Member

@EmCousin can you please give a try to this PR's branch #171 and let us know if this fix works?

@kennyadsl
Copy link
Member

@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
Copy link
Author

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
Copy link
Member

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
Copy link
Member

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
Copy link
Member

I've opened solidusio-contrib/solidus_reviews#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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants