jaredonline / google-authenticator

Ruby gem to implement Google's MFA authenticator
MIT License
307 stars 84 forks source link

Fix `RailsAdapter::LoadedTooLateError` with Zeitwerk #76

Closed kg8m closed 1 year ago

kg8m commented 1 year ago

Fixes #75.

Zeitwerk uses Ruby's built-in autoload, and defined? for an autoload constant always returns "constant". So defined?(::ApplicationController) always returns "constant" in some situations.

After this pull request, GoogleAuthenticatorRails gem will check if ApplicationController is loaded or not by Active Support's descendants instead of defined?. This new way doesn't depend on Ruby's autoload.

kg8m commented 1 year ago

@jaredonline I am sorry to bother you, but could you please check this pull request?

jaredonline commented 1 year ago

Hey @kg8m and folks, sorry it's taken me 2 months to take a look at this. I will merge and roll this out today, thank you for the patch.

kg8m commented 1 year ago

Thanks a lot for your review and merge!