Skip to content

Commit

Permalink
fix: added check for state
Browse files Browse the repository at this point in the history
  • Loading branch information
affrncsp committed Mar 14, 2024
1 parent 4621b13 commit b18ef94
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions includes/wp-affinidi-login-callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
// }

// Authenticate Check and Redirect
if (!isset($_GET['code']) && !isset($_GET['error_description'])) {
if (!isset($_GET['code']) && !isset($_GET['error_description']) && !empty($_GET['state'])) {

// Grab a copy of the options and set the redirect location.
// Grab the state from the Auth URL and send to AL
$state = $_GET['state'];

// generate code verifier and challenge
Expand All @@ -51,6 +51,16 @@
exit;
}

// Check for error
if (empty($_GET['state'])) {
// log error description on server side
$log_message = "Affinidi Login: State is empty".PHP_EOL;
error_log($log_message);
// redirect user with error code
wp_safe_redirect($user_redirect . "?message=affinidi_login_failed");
exit;
}

// retrieve state and get the transient info for redirect
$state = sanitize_text_field($_GET['state']);
$redirect_to = get_transient("affinidi_user_redirect_to".$state);
Expand Down

0 comments on commit b18ef94

Please sign in to comment.