-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attach token name and value to request when persist mode is on #67
Conversation
@@ -159,6 +159,9 @@ public function __invoke(ServerRequestInterface $request, ResponseInterface $res | |||
// Generate new CSRF token if persistentTokenMode is false, or if a valid keyPair has not yet been stored | |||
if (!$this->persistentTokenMode || !$this->loadLastKeyPair()) { | |||
$request = $this->generateNewToken($request); | |||
} elseif ($this->persistentTokenMode) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer if this if-block was changed as it is not very easy to read.
if ($this->persistentTokenMode === false) {
$request = $this->generateNewToken($request);
} else {
$pair = $this->loadLastKeyPair() ? $this->keyPair : $this->generateToken();
$request = $this->attachRequestAttributes($request, $pair);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/cc @akrabat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed it's not really easy to read, but I don't see a prettier way to put it right. Any suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above comments.
Oh, interesting - I didn't think about the fact that Good call on adding unit tests for updating the request object, too. This is a great example of the importance of unit testing. |
The fork has gone away? |
I accidentally deleted it while cleaning my old repos. I don't think it's a problem unless changes are required. In this case I will re-fork it and make a new PR @akrabat |
@akrabat this looks okay to merge; but I cannot :D |
Sorry, I missed your reply @ivandokov I get this:
So I think that a branch is needed. |
@akrabat I re-created the PR so you can merge it now. I'm sorry for the trouble. |
PR #60 introduced persist mode for the token, but there is a BC break. When the persist mode is turned on the token name and value are not attached to the request. This fixes the issue.
PS: @akrabat please add Style CI or something else to format the code in PSR2 because PhpStorm automatically does some whitespace changes and stuff on save and I know from my previous PR that you don't like these.