1 | <?php |
||
35 | class BeUserAuthenticationController implements iAuthenticate |
||
36 | { |
||
37 | /** |
||
38 | * This property defines (when it's set), that this controller should check authentication |
||
39 | * This property will be automatically set by restler, when in the API-class/controller this |
||
40 | * is configured (in PHPdoc/annotations) |
||
41 | * |
||
42 | * Where do we set this property? |
||
43 | * When the property should be used, than it must be set inside the PHPdoc-comment of the API-class-method, |
||
44 | * which handle the API-request |
||
45 | * |
||
46 | * Syntax: |
||
47 | * The PHPdoc-comment must look like this: |
||
48 | * @class [className] {@[propertyName] [propertyValue]} |
||
49 | * |
||
50 | * Example: |
||
51 | * When this controller should be used for authentication-checks, than the PHPdoc-comment must look like this: |
||
52 | * @class Aoe\Restler\Controller\BeUserAuthenticationController {@checkAuthentication true} |
||
53 | * |
||
54 | * @var boolean |
||
55 | */ |
||
56 | public $checkAuthentication = false; |
||
57 | /** |
||
58 | * @var TYPO3Loader |
||
59 | */ |
||
60 | private $typo3Loader; |
||
61 | |||
62 | /** |
||
63 | * @param TYPO3Loader $typo3Loader |
||
64 | */ |
||
65 | 4 | public function __construct(TYPO3Loader $typo3Loader) |
|
69 | |||
70 | /** |
||
71 | * This method checks, if client is allowed to access the requested API-class |
||
72 | * |
||
73 | * @return boolean |
||
74 | */ |
||
75 | 3 | public function __isAllowed() |
|
76 | { |
||
77 | 3 | if ($this->checkAuthentication !== true) { |
|
78 | // this controller is not responsible for the authentication |
||
79 | 1 | return false; |
|
80 | } |
||
81 | |||
82 | 2 | $this->typo3Loader->initializeBackendEndUser(); |
|
83 | |||
84 | 2 | $beUser = $this->typo3Loader->getBackEndUser(); |
|
85 | 2 | if (false === is_array($beUser->user) || empty($beUser->user['uid'])) { |
|
86 | 1 | return false; |
|
87 | } |
||
88 | 1 | return true; |
|
89 | } |
||
90 | |||
91 | /** |
||
92 | * return dummy string, because we DON'T need that for our case (we use NO base-authentification via REST-API) |
||
93 | * |
||
94 | * @return string |
||
95 | * @see Luracast\Restler\iAuthenticate |
||
96 | */ |
||
97 | 1 | public function __getWWWAuthenticateString() |
|
101 | } |
||
102 |