Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
joshcanhelp committed Aug 2, 2018
1 parent 4c07077 commit d480cb2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/admin/WP_Auth0_Admin_Advanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -778,23 +778,24 @@ public function link_accounts_validation( $old_options, $input ) {
* @return array
*/
public function loginredirection_validation( $old_options, $input ) {
$input['default_login_redirection'] = strtolower( $input['default_login_redirection'] );
$new_redirect_url = strtolower( $input['default_login_redirection'] );
$old_redirect_url = strtolower( $old_options['default_login_redirection'] );

// No change so no validation needed.
if ( $input['default_login_redirection'] === $old_options['default_login_redirection'] ) {
if ( $new_redirect_url === $old_redirect_url ) {
return $input;
}

$home_url = home_url();

// Set the default redirection URL to be the homepage.
if ( empty( $input['default_login_redirection'] ) ) {
if ( empty( $new_redirect_url ) ) {
$input['default_login_redirection'] = $home_url;
return $input;
}

$home_url_host = wp_parse_url( $home_url, PHP_URL_HOST );
$redirect_url_host = wp_parse_url( $input['default_login_redirection'], PHP_URL_HOST );
$redirect_url_host = wp_parse_url( $new_redirect_url, PHP_URL_HOST );

// Same host name so it's safe to redirect.
if ( $redirect_url_host === $home_url_host ) {
Expand Down

0 comments on commit d480cb2

Please sign in to comment.