1
|
|
|
<?php |
2
|
|
|
namespace Aoe\FeloginBruteforceProtection\Domain\Service; |
3
|
|
|
|
4
|
|
|
/*************************************************************** |
5
|
|
|
* Copyright notice |
6
|
|
|
* |
7
|
|
|
* (c) 2019 AOE GmbH <[email protected]> |
8
|
|
|
* |
9
|
|
|
* All rights reserved |
10
|
|
|
* |
11
|
|
|
* This script is part of the TYPO3 project. The TYPO3 project is |
12
|
|
|
* free software; you can redistribute it and/or modify |
13
|
|
|
* it under the terms of the GNU General Public License as published by |
14
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
15
|
|
|
* (at your option) any later version. |
16
|
|
|
* |
17
|
|
|
* The GNU General Public License can be found at |
18
|
|
|
* http://www.gnu.org/copyleft/gpl.html. |
19
|
|
|
* |
20
|
|
|
* This script is distributed in the hope that it will be useful, |
21
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
22
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23
|
|
|
* GNU General Public License for more details. |
24
|
|
|
* |
25
|
|
|
* This copyright notice MUST APPEAR in all copies of the script! |
26
|
|
|
***************************************************************/ |
27
|
|
|
|
28
|
|
|
use TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @package Aoe\FeloginBruteforceProtection\Domain\Service |
32
|
|
|
* @author Patrick Roos <[email protected]> |
33
|
|
|
*/ |
34
|
|
|
class RestrictionIdentifierFrontendName extends RestrictionIdentifierAbstract |
35
|
|
|
{ |
36
|
|
|
/** |
37
|
|
|
* @var FrontendUserAuthentication |
38
|
|
|
*/ |
39
|
|
|
protected $frontendUserAuthentication; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* the value of the restriction identifier |
43
|
|
|
* @return string |
44
|
|
|
*/ |
45
|
8 |
|
public function getIdentifierValue() |
46
|
|
|
{ |
47
|
8 |
|
if (!isset($this->identifierValue)) { |
48
|
8 |
|
$loginFormData = $this->frontendUserAuthentication->getLoginFormData(); |
49
|
8 |
|
if (isset($loginFormData['uname']) && !empty($loginFormData['uname'])) { |
50
|
4 |
|
$this->identifierValue = $loginFormData['uname']; |
|
|
|
|
51
|
|
|
} else { |
52
|
4 |
|
$this->identifierValue = ''; |
53
|
|
|
} |
54
|
|
|
} |
55
|
8 |
|
return $this->identifierValue; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* no precondition for frontend name |
60
|
|
|
* @return boolean |
61
|
|
|
*/ |
62
|
2 |
|
public function checkPreconditions() |
63
|
|
|
{ |
64
|
2 |
|
return true; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @param FrontendUserAuthentication $frontendUserAuthentication |
69
|
|
|
* @return void |
70
|
|
|
**/ |
71
|
11 |
|
public function setFrontendUserAuthentication(FrontendUserAuthentication $frontendUserAuthentication) |
72
|
|
|
{ |
73
|
11 |
|
$this->frontendUserAuthentication = $frontendUserAuthentication; |
74
|
11 |
|
} |
75
|
|
|
} |
76
|
|
|
|
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.