Conditions | 4 |
Paths | 3 |
Total Lines | 22 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
31 | public function checkPassword(string $password): int |
||
32 | { |
||
33 | $hash = sha1($password); |
||
34 | $request = GeneralUtility::makeInstance(RequestFactory::class); |
||
35 | $response = $request->request( |
||
36 | self::API_URL . substr($hash, 0, 5), |
||
37 | 'GET', |
||
38 | [ |
||
39 | 'User-Agent' => 'TYPO3 Extension fe_change_pwd', |
||
40 | ] |
||
41 | ); |
||
42 | |||
43 | $results = $response->getBody()->getContents(); |
||
44 | if (($response->getStatusCode() !== 200) || empty($results)) { |
||
45 | // Something went wrong with the request, return 0 and ignore check |
||
46 | return 0; |
||
47 | } |
||
48 | |||
49 | if (preg_match('/' . preg_quote(substr($hash, 5)) . ':([0-9]+)/ism', $results, $matches) === 1) { |
||
50 | return (int)$matches[1]; |
||
51 | } |
||
52 | return 0; |
||
53 | } |
||
55 |