mirror of
https://github.com/discourse/wp-discourse.git
synced 2025-10-03 08:59:21 +08:00
Only parse query_string if it exists (#522)
This commit is contained in:
parent
deacab2662
commit
6b2ba54c8e
1 changed files with 18 additions and 14 deletions
|
@ -51,16 +51,20 @@ class DiscourseSSO extends DiscourseBase {
|
||||||
$bypass_sync = apply_filters( 'wpdc_bypass_sync_sso', false, $user->ID, $user );
|
$bypass_sync = apply_filters( 'wpdc_bypass_sync_sso', false, $user->ID, $user );
|
||||||
|
|
||||||
if ( ! $bypass_sync ) {
|
if ( ! $bypass_sync ) {
|
||||||
// Make sure the login hasn't been initiated by clicking on a SSO login link.
|
// Make sure the login hasn't been initiated by clicking on a SSO login link.
|
||||||
$query_string = wp_parse_url( wp_get_referer(), PHP_URL_QUERY );
|
$query_string = wp_parse_url( wp_get_referer(), PHP_URL_QUERY );
|
||||||
$query_params = array();
|
$query_params = array();
|
||||||
parse_str( $query_string, $query_params );
|
$sso_referer = null;
|
||||||
$sso_referer = ! empty( $query_params['redirect_to'] ) && preg_match( '/^\/\?sso/', $query_params['redirect_to'] );
|
|
||||||
if ( ! $sso_referer ) {
|
|
||||||
$params = $this->get_sso_params( $user );
|
|
||||||
|
|
||||||
$this->sync_sso( $params, $user->ID );
|
if ( ! empty( $query_string ) ) {
|
||||||
}
|
parse_str( $query_string, $query_params );
|
||||||
|
$sso_referer = ! empty( $query_params['redirect_to'] ) && preg_match( '/^\/\?sso/', $query_params['redirect_to'] );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! $sso_referer ) {
|
||||||
|
$params = $this->get_sso_params( $user );
|
||||||
|
$this->sync_sso( $params, $user->ID );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -257,11 +261,11 @@ class DiscourseSSO extends DiscourseBase {
|
||||||
return new \WP_Error( $type, isset( $args['message'] ) ? $args['message'] : 'SSO error' );
|
return new \WP_Error( $type, isset( $args['message'] ) ? $args['message'] : 'SSO error' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle redirects
|
* Handle redirects
|
||||||
*
|
*
|
||||||
* @param string $url Url to redirect to.
|
* @param string $url Url to redirect to.
|
||||||
*/
|
*/
|
||||||
public function redirect_to( $url ) {
|
public function redirect_to( $url ) {
|
||||||
wp_safe_redirect( esc_url_raw( $url ) );
|
wp_safe_redirect( esc_url_raw( $url ) );
|
||||||
exit;
|
exit;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue