Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dd882db

Browse filesBrowse files
committed
minor #59214 [Security][SecurityBundle] rename userIsGranted() to isGrantedForUser() (xabbuh)
This PR was merged into the 7.3 branch. Discussion ---------- [Security][SecurityBundle] rename userIsGranted() to isGrantedForUser() | Q | A | ------------- | --- | Branch? | 7.3 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | see #48142 (comment) | License | MIT Commits ------- 278d62c rename userIsGranted() to isGrantedForUser()
2 parents 30b8038 + 278d62c commit dd882db
Copy full SHA for dd882db

File tree

7 files changed

+10
-10
lines changed
Filter options

7 files changed

+10
-10
lines changed

‎src/Symfony/Bundle/SecurityBundle/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/CHANGELOG.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ CHANGELOG
44
7.3
55
---
66

7-
* Add `Security::userIsGranted()` to test user authorization without relying on the session. For example, users not currently logged in, or while processing a message from a message queue
7+
* Add `Security::isGrantedForUser()` to test user authorization without relying on the session. For example, users not currently logged in, or while processing a message from a message queue
88

99
7.2
1010
---

‎src/Symfony/Bundle/SecurityBundle/Security.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Security.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,10 @@ public function logout(bool $validateCsrfToken = true): ?Response
154154
*
155155
* This should be used over isGranted() when checking permissions against a user that is not currently logged in or while in a CLI context.
156156
*/
157-
public function userIsGranted(UserInterface $user, mixed $attribute, mixed $subject = null): bool
157+
public function isGrantedForUser(UserInterface $user, mixed $attribute, mixed $subject = null): bool
158158
{
159159
return $this->container->get('security.user_authorization_checker')
160-
->userIsGranted($user, $attribute, $subject);
160+
->isGrantedForUser($user, $attribute, $subject);
161161
}
162162

163163
private function getAuthenticator(?string $authenticatorName, string $firewallName): AuthenticatorInterface

‎src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ public function testUserAuthorizationChecker()
6161
$security = $container->get('functional_test.security.helper');
6262
$this->assertTrue($security->isGranted('ROLE_FOO'));
6363
$this->assertFalse($security->isGranted('ROLE_BAR'));
64-
$this->assertTrue($security->userIsGranted($offlineUser, 'ROLE_BAR'));
65-
$this->assertFalse($security->userIsGranted($offlineUser, 'ROLE_FOO'));
64+
$this->assertTrue($security->isGrantedForUser($offlineUser, 'ROLE_BAR'));
65+
$this->assertFalse($security->isGrantedForUser($offlineUser, 'ROLE_FOO'));
6666
}
6767

6868
/**

‎src/Symfony/Component/Security/Core/Authorization/UserAuthorizationChecker.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Authorization/UserAuthorizationChecker.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function __construct(
2424
) {
2525
}
2626

27-
public function userIsGranted(UserInterface $user, mixed $attribute, mixed $subject = null): bool
27+
public function isGrantedForUser(UserInterface $user, mixed $attribute, mixed $subject = null): bool
2828
{
2929
return $this->accessDecisionManager->decide(new UserAuthorizationCheckerToken($user), [$attribute], $subject);
3030
}

‎src/Symfony/Component/Security/Core/Authorization/UserAuthorizationCheckerInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Authorization/UserAuthorizationCheckerInterface.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ interface UserAuthorizationCheckerInterface
2525
*
2626
* @param mixed $attribute A single attribute to vote on (can be of any type, string and instance of Expression are supported by the core)
2727
*/
28-
public function userIsGranted(UserInterface $user, mixed $attribute, mixed $subject = null): bool;
28+
public function isGrantedForUser(UserInterface $user, mixed $attribute, mixed $subject = null): bool;
2929
}

‎src/Symfony/Component/Security/Core/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/CHANGELOG.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ CHANGELOG
44
7.3
55
---
66

7-
* Add `UserAuthorizationChecker::userIsGranted()` to test user authorization without relying on the session.
7+
* Add `UserAuthorizationChecker::isGrantedForUser()` to test user authorization without relying on the session.
88
For example, users not currently logged in, or while processing a message from a message queue.
99
* Add `OfflineTokenInterface` to mark tokens that do not represent the currently logged-in user
1010

‎src/Symfony/Component/Security/Core/Tests/Authorization/UserAuthorizationCheckerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Tests/Authorization/UserAuthorizationCheckerTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function testIsGranted(bool $decide, array $roles)
4343
->with($this->callback(fn (UserAuthorizationCheckerToken $token): bool => $user === $token->getUser()), $this->identicalTo(['ROLE_FOO']))
4444
->willReturn($decide);
4545

46-
$this->assertSame($decide, $this->authorizationChecker->userIsGranted($user, 'ROLE_FOO'));
46+
$this->assertSame($decide, $this->authorizationChecker->isGrantedForUser($user, 'ROLE_FOO'));
4747
}
4848

4949
public static function isGrantedProvider(): array
@@ -65,6 +65,6 @@ public function testIsGrantedWithObjectAttribute()
6565
->method('decide')
6666
->with($this->isInstanceOf($token::class), $this->identicalTo([$attribute]))
6767
->willReturn(true);
68-
$this->assertTrue($this->authorizationChecker->userIsGranted($token->getUser(), $attribute));
68+
$this->assertTrue($this->authorizationChecker->isGrantedForUser($token->getUser(), $attribute));
6969
}
7070
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.