Skip to content

Commit

Permalink
add nice error message when exchange of token returns 401 #11 (now i…
Browse files Browse the repository at this point in the history
…t manages the errores when there is no code and an error instead)
  • Loading branch information
glena committed Oct 16, 2014
1 parent 27f86e7 commit 1c5039c
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions WP_Auth0.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public static function init(){

add_action( 'widgets_init', array(__CLASS__, 'wp_register_widget'));

add_filter('query_vars', array(__CLASS__, 'a0_register_query_vars'));


$plugin = plugin_basename(__FILE__);
add_filter("plugin_action_links_$plugin", array(__CLASS__, 'wp_add_plugin_settings_link'));

Expand All @@ -65,6 +68,11 @@ public static function init(){
WP_Auth0_ErrorLog::init();
}

public static function a0_register_query_vars( $qvars ) {
$qvars[] = 'error_description';
return $qvars;
}

public static function a0_render_message()
{
$message = null;
Expand Down Expand Up @@ -241,6 +249,25 @@ public static function init_auth0(){
return;
}

if (isset($wp_query->query_vars['error_description']))
{
$msg = __('Sorry, there was a problem logging you in.', WPA0_LANG);
$msg .= '<br/>';
$msg .= ' '.$wp_query->query_vars['error_description'];
$msg .= '<br/><br/>';
$msg .= '<a href="' . wp_login_url() . '">' . __('← Login', WPA0_LANG) . '</a>';
wp_die($msg);
}
if (isset($wp_query->query_vars['error']))
{
$msg = __('Sorry, there was a problem logging you in.', WPA0_LANG);
$msg .= '<br/>';
$msg .= ' '.$wp_query->query_vars['error'];
$msg .= '<br/><br/>';
$msg .= '<a href="' . wp_login_url() . '">' . __('← Login', WPA0_LANG) . '</a>';
wp_die($msg);
}

$code = $wp_query->query_vars['code'];
$state = $wp_query->query_vars['state'];
$stateFromGet = json_decode(stripcslashes($state));
Expand Down

0 comments on commit 1c5039c

Please sign in to comment.