-
Notifications
You must be signed in to change notification settings - Fork 154
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
Add action 'openid-connect-generic-register-login-form' #241
base: develop
Are you sure you want to change the base?
Conversation
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.
@grothoff there are a bunch of unexpected changes all over the README file. Can you ensure that you only touch the lines you are adding?
I need to review your use case for this some as I'm not quite following why this is needed.
@grothoff also, please run the local development setup as your code changes didn't pass code quality and static analysis checks. These checks should have been performed before your local commit was even allowed but it appears you didn't setup your local development environment properly. |
3a7b2d4
to
97e36e2
Compare
make it possible to grab the login form object and trigger it from other pages, such as the WooCommerce checkout page.
I've modified the patch to undo the removal of whitespaces my editor did automatically, and ensured that the CI passes (not sure why it did not run on my first commit, when I fixed the whitespace it did run automatically this time). |
Hi there! Merging is somehow still 'blocked' by Github with "1 change requested", but I don't know what else I am asked to change (if anything), or if this is simply waiting for a review from @daggerhart. Please do tell me if there is something left for me to do here. |
@grothoff I'm looking at the example code you provided in the README updates and I'm not understanding why you are not just using the |
add_action ('openid-connect-generic-register-login-form', | ||
function ( $login_form ) { | ||
|
||
// show login form at the shopping cart (if not logged in) | ||
add_action( 'woocommerce_before_checkout_billing_form', | ||
function () use ( $login_form ) { | ||
$user = wp_get_current_user (); | ||
if (0 == $user->ID) { | ||
// ID 0 is used to indicate user is not logged in. | ||
// Re-use filter logic to generate login page | ||
print ( $login_form->handle_login_page ('') ); | ||
} | ||
}); | ||
|
||
// Add action to set cookie to redirect back to current | ||
// (checkout) page after OIDC provided the data | ||
add_action( 'woocommerce_before_checkout_billing_form', | ||
array( $login_form, 'handle_redirect_cookie' ) ); | ||
|
||
} | ||
); |
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.
This example leads me to believe that there is an attempt to get the login form which should already be available by using the openid_connect_generic_login_button
shortcode.
You are right that I'm trying to get the login form. However, if I just do:
then the 'handle_redirect_cookie' logic is not run, and after the login the user is back on the front page instead of continuing with the checkout. Right now, my latest (cleaner) snippet looks like this to get the redirect cookie:
I don't see a way to also set the redirect cookie with the shortcode. Is there? |
So there is some undocumented features of the shortcode. You can actually set the |
I have tried explicitly with the target URL echo do_shortcode( '[openid_connect_generic_login_button redirect_to="127.0.0.1:9999/?page_id=14"]' ); and (preferred by me) echo do_shortcode( '[openid_connect_generic_login_button redirect_to="yes"]' ); and echo do_shortcode( '[openid_connect_generic_login_button redirect_to]' ); None of them set the cookie, I always get dropped back onto the front page after login. |
The |
Also, it seems you should be turning on permalinks as I'm not sure that setting the redirect URL using query parameters works. I'll run through some tests in the shortcode to confirm this. |
I also tried with an http://-prefix for the URI, and using absolute URLs. Nothing works. I am indeed testing with Wordpress 5.5.1. |
Oh, and I'm not surprised that it doesn't work with the shortcode, as the function to set the cookie is AFAIK only called in a hook that is run on the main Wordpress page. (See the 2nd action I'm adding in the snippet.) |
The site I am using is only to test the GNU Taler payment plugin with the re:claim integration. The code should eventually run on various WooCommerce sites, and ideally not require those sites to have any particular other settings (like enabled permalinks). But yes, putting that link like this sucks --- and I'm aware it is too fragile, but for now I'm just trying to get your solution to work at all. |
@grothoff actually no, the login button shortcode does call the |
This action makes it possible to grab the login form object and trigger
it from other pages, such as the WooCommerce checkout page.
All Submissions:
Have you followed the plugin Contributing guideline?
Get a 404.
Does your code follow the WordPress' coding standards?
Have you checked to ensure there aren't other open Pull Requests for the same update/change?
Changes proposed in this Pull Request:
I needed this action for to integrate the plugin with WooCommerce. You can see a more comprehensive example where we integrated WooCommerce, Re:claimID and GNU Taler at https://git.taler.net/woocommerce-taler.git/ to create a one-click account-less shopping experience by providing the shipping/billing address data via OIDC (and OIDC implemented via Re:claim on top of the GNU Name System). This 2-line action was the smallest change I could imagine to use your plugin for the OIDC implementation.
How to test the changes in this Pull Request:
Other information:
Changelog entry
Add action 'openid-connect-generic-register-login-form' to make it
possible to grab the login form object and trigger the login.