Skip to content

Commit 535eb8a

Browse files
authored
Merge pull request facebookarchive#628 from SammyK/master
Reset the CSRF so that it does not get reused
2 parents b44e2f4 + 499d0e4 commit 535eb8a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/Facebook/Helpers/FacebookRedirectLoginHelper.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ public function getAccessToken($redirectUrl = null)
219219
}
220220

221221
$this->validateCsrf();
222+
$this->resetCsrf();
222223

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

254+
/**
255+
* Resets the CSRF so that it doesn't get reused.
256+
*/
257+
private function resetCsrf()
258+
{
259+
$this->persistentDataHandler->set('state', null);
260+
}
261+
253262
/**
254263
* Return the code.
255264
*

0 commit comments

Comments
 (0)