-
Notifications
You must be signed in to change notification settings - Fork 33
fix: redirect when login URL is modified by third-party plugins during Google OneTap login #306
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -215,7 +215,15 @@ public static function get_redirect_url(): string { | |
| // Initializing the default with admin URL. | ||
| $default_redirect_url = admin_url(); | ||
|
|
||
| if ( 'wp-login.php' === $pagenow ) { | ||
| $wp_login_url = trailingslashit( wp_login_url() ); | ||
|
|
||
| // Get the current page URL. | ||
| $scheme = ( ! empty( $_SERVER['HTTPS'] ) && 'off' !== $_SERVER['HTTPS'] ) ? 'https' : 'http'; | ||
| $host = isset( $_SERVER['HTTP_HOST'] ) ? sanitize_text_field( $_SERVER['HTTP_HOST'] ) : wp_parse_url( site_url(), PHP_URL_HOST ); | ||
|
Comment on lines
+221
to
+222
|
||
| $path = isset( $_SERVER['REQUEST_URI'] ) ? wp_parse_url( sanitize_text_field( $_SERVER['REQUEST_URI'] ), PHP_URL_PATH ) : ''; | ||
|
Comment on lines
+222
to
+223
|
||
| $current_page_url = trailingslashit( $scheme . '://' . $host . $path ); | ||
|
||
|
|
||
| if ( 'wp-login.php' === $pagenow || $current_page_url === $wp_login_url ) { | ||
| // If any redirect_to query parameter is available. | ||
| $redirect_to = filter_input( INPUT_GET, 'redirect_to', FILTER_SANITIZE_URL ); | ||
|
|
||
|
|
||
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.
The new URL detection logic for custom login URLs lacks test coverage. Given that the repository has comprehensive tests for other utility functions (GoogleClient, TokenVerifier, Authenticator), this new functionality should have corresponding unit tests to verify the URL comparison works correctly with various custom login URL scenarios.