Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * {@inheritdoc}
- */
- public function vote(TokenInterface $token, $object, array $attributes)
- {
- $result = VoterInterface::ACCESS_ABSTAIN;
- foreach ($attributes as $attribute) {
- if (!$this->supportsAttribute($attribute)) {
- continue;
- }
- $result = VoterInterface::ACCESS_DENIED;
- if (self::IS_AUTHENTICATED_FULLY === $attribute
- && $this->authenticationTrustResolver->isFullFledged($token)) {
- return VoterInterface::ACCESS_GRANTED;
- }
- if (self::IS_AUTHENTICATED_REMEMBERED === $attribute
- && ($this->authenticationTrustResolver->isRememberMe($token)
- || $this->authenticationTrustResolver->isFullFledged($token))) {
- return VoterInterface::ACCESS_GRANTED;
- }
- if (self::IS_AUTHENTICATED_ANONYMOUSLY === $attribute
- && ($this->authenticationTrustResolver->isAnonymous($token)
- || $this->authenticationTrustResolver->isRememberMe($token)
- || $this->authenticationTrustResolver->isFullFledged($token))) {
- return VoterInterface::ACCESS_GRANTED;
- }
- }
- return $result;
- }
- public function isAuthenticated()
- {
- $securityContext = $this->container->get('security.context');
- return $securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED');
- }
- if (isAuthenticated()) {
- throw $this->createNotFoundException('This page does not exist');
- }
- /**
- * {@inheritdoc}
- */
- public function vote(TokenInterface $token, $object, array $attributes)
- {
- $result = VoterInterface::ACCESS_ABSTAIN;
- foreach ($attributes as $attribute) {
- if (!$this->supportsAttribute($attribute)) {
- continue;
- }
- $result = VoterInterface::ACCESS_DENIED;
- if (self::IS_AUTHENTICATED_FULLY === $attribute
- && $this->authenticationTrustResolver->isFullFledged($token)) {
- return VoterInterface::ACCESS_GRANTED;
- }
- if (self::IS_AUTHENTICATED_REMEMBERED === $attribute
- && $this->authenticationTrustResolver->isRememberMe($token)) {
- return VoterInterface::ACCESS_GRANTED;
- }
- if (self::IS_AUTHENTICATED_ANONYMOUSLY === $attribute
- && $this->authenticationTrustResolver->isAnonymous($token)) {
- return VoterInterface::ACCESS_GRANTED;
- }
- }
- return $result;
- }
- pp_security.apikey_authenticated_voter:
- class: %pp_security.apikey_authenticated_voter.class%
- arguments:
- - "@security.authentication.trust_resolver"
- public: false
- tags:
- - { name: security.voter }
- security:
- access_decision_manager:
- strategy: unanimous
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement