Skip to content

Set User Class on Boot#252

Merged
tvdeyen merged 2 commits intosolidusio:mainfrom
mamhoff:set-user-class-early
Dec 17, 2024
Merged

Set User Class on Boot#252
tvdeyen merged 2 commits intosolidusio:mainfrom
mamhoff:set-user-class-early

Conversation

@mamhoff
Copy link
Copy Markdown
Contributor

@mamhoff mamhoff commented Nov 30, 2024

For most of the Rails boot process, an app running solidus_auth_devise believes that its user class is whatever is configured in the config/spree.rb initializer. However, if solidus_auth_devise is installed, that is changed after most things have been configured.

It need not be this way: If we want this gem to set a default, we should set it really early on, not in one of the last initializers to run (they also run alphabetically, so solidus_auth_devise initializers run quite late).

Specifically, for using the new patch mechanism in https://github.com/friendlycart/flickwerk, Spree.user_class needs to be correct by the time the Rails finisher runs (when the setup_main_autoloader initializer runs).

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

  • 📖 I have updated the README to account for my changes.
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

@mamhoff mamhoff force-pushed the set-user-class-early branch from b8863d2 to 008d9b1 Compare December 16, 2024 14:23
@tvdeyen
Copy link
Copy Markdown
Member

tvdeyen commented Dec 16, 2024

Specs fixed by #253

@tvdeyen tvdeyen force-pushed the set-user-class-early branch from 008d9b1 to 421273f Compare December 16, 2024 18:59
@tvdeyen tvdeyen enabled auto-merge December 16, 2024 18:59
For most of the Rails boot process, an app running solidus_auth_devise
believes that its user class is whatever is configured in the
config/spree.rb initializer. However, if `solidus_auth_devise` is
installed, that is changed after most things have been configured.

It need not be this way: If we want this gem to set a default, we should
set it really early on, not in one of the last initializers to run (they
also run alphabetically, so `solidus_auth_devise` initializers run quite
late.
auto-merge was automatically disabled December 17, 2024 09:55

Head branch was pushed to by a user without write access

@mamhoff mamhoff force-pushed the set-user-class-early branch from 421273f to 14d176f Compare December 17, 2024 09:55
With the generated dummy `spree.rb` now running after the default in the
solidus_auth_devise `engine.rb`, we need to make sure that
`config/initializers/spree.rb` contains the correct user class. Before
this commit, it would generate one with the `Spree::LegacyUser`.
@tvdeyen tvdeyen merged commit 361b739 into solidusio:main Dec 17, 2024
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 this pull request may close these issues.

3 participants