• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

FastyBird / simple-auth / 9758270021

02 Jul 2024 09:15AM UTC coverage: 66.025% (-0.1%) from 66.14%
9758270021

push

github

web-flow
Fixing access to presenter props (#4)

* Fixing access to presenter props

* QA fix

0 of 3 new or added lines in 1 file covered. (0.0%)

377 of 571 relevant lines covered (66.02%)

4.27 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Application/TSimpleAuth.php
1
<?php declare(strict_types = 1);
2

3
/**
4
 * TSimpleAuth.php
5
 *
6
 * @license        More in LICENSE.md
7
 * @copyright      https://www.fastybird.com
8
 * @author         Adam Kadlec <adam.kadlec@fastybird.com>
9
 * @package        FastyBird:SimpleAuth!
10
 * @subpackage     Application
11
 * @since          1.0.0
12
 *
13
 * @date           01.07.24
14
 */
15

16
namespace FastyBird\SimpleAuth\Application;
17

18
use FastyBird\SimpleAuth;
19
use FastyBird\SimpleAuth\Security;
20
use Nette\Application;
21
use ReflectionClass;
22
use ReflectionMethod;
23

24
/**
25
 * Nette's presenters security trait
26
 *
27
 * @package        FastyBird:SimpleAuth!
28
 * @subpackage     Subscribers
29
 *
30
 * @author         Adam Kadlec <adam.kadlec@fastybird.com>
31
 *
32
 * @method Application\IPresenter getPresenter()
33
 * @method string storeRequest(string $expiration = '+ 10 minutes')
34
 */
35
trait TSimpleAuth
36
{
37

38
        protected SimpleAuth\Configuration $simpleAuthConfiguration;
39

40
        protected Security\AnnotationChecker $annotationChecker;
41

42
        protected Security\User|null $simpleUser = null;
43

44
        public function injectSimpleAuth(
45
                Security\AnnotationChecker $annotationChecker,
46
                SimpleAuth\Configuration $configuration,
47
                Security\User|null $simpleUser = null,
48
        ): void
49
        {
50
                $this->annotationChecker = $annotationChecker;
×
51
                $this->simpleAuthConfiguration = $configuration;
×
NEW
52
                $this->simpleUser = $simpleUser;
×
53
        }
54

55
        /**
56
         * @param mixed $element
57
         *
58
         * @throws Application\ForbiddenRequestException
59
         * @throws Application\UI\InvalidLinkException
60
         */
61
        public function checkRequirements(ReflectionClass|ReflectionMethod $element): void
62
        {
63
                $redirectUrl = $this->simpleAuthConfiguration->getRedirectUrl([
×
64
                        'backlink' => $this->storeRequest(),
×
65
                ]);
×
66

67
                try {
68
                        parent::checkRequirements($element);
×
69

70
                        if (!$this->annotationChecker->checkAccess(
×
NEW
71
                                $this->simpleUser,
×
NEW
72
                                $element instanceof ReflectionClass ? $element->name : $element->class,
×
73
                                $element instanceof ReflectionMethod ? $element->name : null,
×
74
                        )) {
×
75
                                throw new Application\ForbiddenRequestException();
×
76
                        }
77
                } catch (Application\ForbiddenRequestException $ex) {
×
78
                        if ($redirectUrl) {
×
79
                                $this->getPresenter()->redirectUrl($redirectUrl);
×
80

81
                        } else {
82
                                throw $ex;
×
83
                        }
84
                }
85
        }
86

87
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc