Skip to content
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

Changing home_url() to site_url(), wp_login_url(), and wp_logout_url() #360

Merged
merged 10 commits into from
Jan 15, 2018

Conversation

joshcanhelp
Copy link
Contributor

This pull request fixes #339 and #342 as well as a number of other instances of home_url(). The only time home_url() should be used is to display a front-end page of the site. For most installs, these two will be the same but for the ones that aren't this change is is important.

…xpected rather than a site page; changed home_urL() to wp_login_url() or wp_logout_url() where appropriate
@joshcanhelp joshcanhelp requested review from cocojoe and glena January 12, 2018 21:09
@joshcanhelp joshcanhelp added this to the v3-Next milestone Jan 12, 2018
@joshcanhelp joshcanhelp changed the base branch from master to dev January 12, 2018 21:29
Copy link
Member

@cocojoe cocojoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you checked the output for example when the new client is setup that that values are exactly the same as before?

),
"allowed_origins"=>array(
home_url( '/wp-login.php' )
wp_login_url()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cocojoe - Plugin is formatted both ways throughout ... my IDE can be configured whatever way. Any opinion on what we should stick with? I'm impartial.

$response = wp_remote_post( $endpoint , array(
'method' => 'POST',
'headers' => $headers,
'body' => json_encode( array(
'name' => $name,
'callbacks' => array(
home_url( '/index.php?auth0=1' ),
home_url( '/wp-login.php' )
site_url( 'index.php?auth0=1' ),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the site_url always includes the trailing slash?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cocojoe - It will correct either way:

# site_url( 'index.php' ):
http://localhost/index.php

# site_url( '/index.php' ):
http://localhost/index.php

# home_url( '/index.php' ):
http://localhost/index.php

# home_url( 'index.php' ):
http://localhost/index.php


$get_user_script = str_replace( '{THE_WS_TOKEN}', $migration_token, WP_Auth0_CustomDBLib::$get_user_script );
$get_user_script = str_replace( '{THE_WS_URL}', get_home_url() . '/index.php?a0_action=migration-ws-get-user', $get_user_script );
$get_user_script = str_replace( '{THE_WS_URL}', site_url(), $get_user_script );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this one $get_user_script but the previous one is index.php?a0_action=migration-ws-login even though appears to be a $login_script ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cocojoe - Eeks, big miss on my part. Fixing.

@@ -91,14 +91,12 @@ public function logout() {
$auto_login = absint( $this->a0_options->get( 'auto_login' ) );

if ( $slo && isset( $_REQUEST['SLO'] ) ) {
$redirect_to = $_REQUEST['redirect_to'];
wp_redirect( $redirect_to );
wp_redirect( $_REQUEST['redirect_to'] );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this wp_redirect method validate the redirect_to in some way?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cocojoe - Uses wp_sanitize_redirect()

@@ -138,7 +138,7 @@ protected function defaults() {
'auto_provisioning' => false,
'default_login_redirection' => home_url(),

'auth0_server_domain' => 'auth0.auth0.com',
'auth0_server_domain' => 'auth0.auth0.com',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting

@@ -80,14 +80,14 @@
return p;
}, {});

post('<?php echo home_url( '/index.php?auth0=implicit' ); ?>', {
post('<?php echo site_url( 'index.php?auth0=implicit' ); ?>', {
token:data.id_token,
state:data.state
}, 'POST');
}

// lock.on("authenticated", function(authResult) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe time to just remove this commented code?

@joshcanhelp
Copy link
Contributor Author

@cocojoe - For your first question ... the values shouldn't be exactly the same as before, that's part of the issue. It was something I flagged in my initial review of the plugin (local notes).

@joshcanhelp
Copy link
Contributor Author

@cocojoe - Ready for re-review

Copy link
Member

@cocojoe cocojoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks better

cocojoe and others added 3 commits January 15, 2018 12:07
* Added RS256 JWT Support (Default for New Clients)
* Add caching to JWKS fetching
* Added Lock 11, Update SSO (#350)
* Fixed Admin migration step in Setup Wizard
* Added WP_Auth0_Api_Client::signup_user
…xpected rather than a site page; changed home_urL() to wp_login_url() or wp_logout_url() where appropriate
@cocojoe cocojoe merged commit 213f88e into dev Jan 15, 2018
@cocojoe cocojoe deleted the changed-home-url-to-site-url branch January 18, 2018 09:50
@cocojoe cocojoe mentioned this pull request Jan 25, 2018
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants