-
Notifications
You must be signed in to change notification settings - Fork 4
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
Call before/after_create_account
if before/after_omniauth_create_account
is not provided
#30
base: master
Are you sure you want to change the base?
Conversation
…ccount` is not provided Since it uses the `login` plugin, our `after_login` continues to work as expected when we introduce the `rodauth-omniauth` plugin to our application. However, since `rodauth-omniauth` defines its own `new_account` and `save_account` methods, we need to override `before/after_omniauth_create_account`. I think it would be better if the `rodauth-omniauth` plugin called `before/after_create_account` when `before/after_omniauth_create_account` is not provided. This change will help integrate the `rodauth-omniauth` plugin into existing applications without extra work. In the next steps, `rodauth-omniauth` may also call `new_account` and `save_account` from Rodauth. These methods look very similar to the original `new_account` and `save_account` methods in Rodauth.
Hi @janko, I found it useful, but what do you think? |
def _before_omniauth_create_account | ||
before_create_account | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jeremyevans, is this the correct way to provide default methods for before
and after
hooks in Rodauth world?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You would want to remove the existing method first, but that that is the correct method to override. I don't think it is a good idea to call hook method explicitly inside other hook methods by default, though.
The approach I would recommend, if the behavior in this pull request is desired, is for the omniauth code that creates accounts to call the before_create_account
and after_create_accounts
methods separately (before or after calling the before_omniauth_create_account
and after_omniauth_create_account
methods). For backwards compatibility, that would likely have to be conditional and off by default, though.
I'm not sure it's a good idea to call FWIW, one feature I would like to add to rodauth-omniauth eventually is redirecting to the create account form after OmniAuth login, to require the account to be created explicitly and allow for any additional account fields that might be required by the app. In that case, that would happen through the classic create account form, so it would trigger the |
Since it uses the
login
plugin, ourafter_login
continues to work as expected when we introduce therodauth-omniauth
plugin to our application.However, since
rodauth-omniauth
defines its ownnew_account
andsave_account
methods, we need to overridebefore/after_omniauth_create_account
.I think it would be better if the
rodauth-omniauth
plugin calledbefore/after_create_account
whenbefore/after_omniauth_create_account
is not provided.This change will help integrate the
rodauth-omniauth
plugin into existing applications without extra work.In the next steps,
rodauth-omniauth
may also callnew_account
andsave_account
from Rodauth. These methods look very similar to the originalnew_account
andsave_account
methods in Rodauth.