Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Reset the CSRF so that it does not get reused #628

Merged
merged 1 commit into from
Aug 6, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/Facebook/Helpers/FacebookRedirectLoginHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ public function getAccessToken($redirectUrl = null)
}

$this->validateCsrf();
$this->resetCsrf();

$redirectUrl = $redirectUrl ?: $this->urlDetectionHandler->getCurrentUrl();
// At minimum we need to remove the state param
Expand Down Expand Up @@ -250,6 +251,14 @@ protected function validateCsrf()
throw new FacebookSDKException('Cross-site request forgery validation failed. The "state" param from the URL and session do not match.');
}

/**
* Resets the CSRF so that it doesn't get reused.
*/
private function resetCsrf()
{
$this->persistentDataHandler->set('state', null);
}

/**
* Return the code.
*
Expand Down