Problem/Motivation

The CsrfTokenGenerator service currently gets the request set, just to get the _account attribute. Now that we have a current_user service, we can just inject this instead. This should be more reliable as well as being able to remove the setRequest() method.

Proposed resolution

Inject current_user service, remove request usage, convert tests

Remaining tasks

See above, Resolve current_user request scope issues.

User interface changes

None

API changes

None

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

damiankloip’s picture

damiankloip’s picture

Status: Active » Needs review
dawehner’s picture

Note: this won't work when we put back the request scope back as the token generator is used outside of the request response. Maybe we could try to make the user service optional as only the generate method is used outside of the request scope.

damiankloip’s picture

FileSize
2.39 KB
5.53 KB

Yes, I like that idea. Let's do that.

Status: Needs review » Needs work

The last submitted patch, 2076703-4.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review

#4: 2076703-4.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 2076703-4.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
FileSize
510 bytes
5.53 KB
dawehner’s picture

+++ b/core/lib/Drupal/Core/Access/CsrfTokenGenerator.php
@@ -26,30 +27,32 @@ class CsrfTokenGenerator {
+   * @param \Drupal\Core\Session\AccountInterface
+   *   The current user account.
    */

Unneeded...

damiankloip’s picture

FileSize
584 bytes
5.33 KB

Totally.

Status: Needs review » Needs work

The last submitted patch, 2076703-10.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review

#10: 2076703-10.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 2076703-10.patch, failed testing.

damiankloip’s picture

I just removed a docblock... :(

damiankloip’s picture

damiankloip’s picture

Issue summary: View changes
Status: Needs work » Closed (duplicate)