1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
namespace Derhansen\FeChangePwd\Controller; |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Extension "fe_change_pwd" for TYPO3 CMS. |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please read the |
9
|
|
|
* LICENSE.txt file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
use Derhansen\FeChangePwd\Domain\Model\Dto\ChangePassword; |
13
|
|
|
use Derhansen\FeChangePwd\Service\FrontendUserService; |
14
|
|
|
use TYPO3\CMS\Extbase\Utility\LocalizationUtility; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Class PasswordController |
18
|
|
|
*/ |
19
|
|
|
class PasswordController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var FrontendUserService |
23
|
|
|
*/ |
24
|
|
|
protected $frontendUserService = null; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @param FrontendUserService $frontendUserService |
28
|
|
|
*/ |
29
|
|
|
public function injectFrontendUserService( |
30
|
|
|
\Derhansen\FeChangePwd\Service\FrontendUserService $frontendUserService |
31
|
|
|
) { |
32
|
|
|
$this->frontendUserService = $frontendUserService; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Edit action |
37
|
|
|
* |
38
|
|
|
* @return void |
39
|
|
|
*/ |
40
|
|
|
public function editAction() |
41
|
|
|
{ |
42
|
|
|
$changePassword = $this->objectManager->get(ChangePassword::class); |
43
|
|
|
$this->view->assignMultiple([ |
44
|
|
|
'changePasswordReason' => $this->frontendUserService->getMustChangePasswordReason(), |
45
|
|
|
'changePassword' => $changePassword |
46
|
|
|
]); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Update action |
51
|
|
|
* |
52
|
|
|
* @param \Derhansen\FeChangePwd\Domain\Model\Dto\ChangePassword $changePassword |
53
|
|
|
* @validate $changePassword \Derhansen\FeChangePwd\Validation\Validator\ChangePasswordValidator |
54
|
|
|
* |
55
|
|
|
* @return void |
56
|
|
|
*/ |
57
|
|
|
public function updateAction(ChangePassword $changePassword) |
58
|
|
|
{ |
59
|
|
|
$this->frontendUserService->updatePassword($changePassword->getPassword1()); |
60
|
|
|
if (isset($this->settings['afterPasswordChangeAction']) && |
61
|
|
|
$this->settings['afterPasswordChangeAction'] === 'redirect') { |
62
|
|
|
$this->addFlashMessage( |
63
|
|
|
LocalizationUtility::translate('passwordUpdated', 'fe_change_pwd'), |
64
|
|
|
LocalizationUtility::translate('passwordUpdated.title', 'fe_change_pwd') |
65
|
|
|
); |
66
|
|
|
$this->redirect('edit'); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Suppress default flash messages |
72
|
|
|
* |
73
|
|
|
* @return bool |
74
|
|
|
*/ |
75
|
|
|
protected function getErrorFlashMessage() |
76
|
|
|
{ |
77
|
|
|
return false; |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|