Skip to content

Commit

Permalink
state param fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bessudnov committed Sep 26, 2019
1 parent da536aa commit a33d2da
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions example.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* Просто отображаем кнопку авторизации или получаем ссылку для авторизации
* По-умолчанию - отображаем кнопку
*/
$_SESSION['oauth2state'] = $provider->getState();
$_SESSION['oauth2state'] = bin2hex(random_bytes(16));
if (true) {
echo '<div>
<script
Expand All @@ -49,7 +49,7 @@ class="amocrm_oauth"
</script>';
die;
} else {
$authorizationUrl = $provider->getAuthorizationUrl();
$authorizationUrl = $provider->getAuthorizationUrl(['state' => $_SESSION['oauth2state']]);
header('Location: ' . $authorizationUrl);
}
} elseif (empty($_GET['state']) || empty($_SESSION['oauth2state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {
Expand Down

0 comments on commit a33d2da

Please sign in to comment.