Skip to content

Commit 80f0d73

Browse files
author
Nicolas Heist
committed
REFACTOR: Add/remove usages and improve flash messages
1 parent 2196570 commit 80f0d73

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

Classes/Controller/AbstractTwoFactorAuthenticationController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22
namespace Yeebase\TwoFactorAuthentication\Controller;
33

4-
use Neos\Flow\Annotations as Flow;
54
use Neos\Flow\Security\Authentication\Controller\AbstractAuthenticationController;
65

76
abstract class AbstractTwoFactorAuthenticationController extends AbstractAuthenticationController

Classes/Controller/AbstractTwoFactorAuthenticationManagementController.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,18 @@
44
use Neos\Flow\Annotations as Flow;
55
use Neos\Error\Messages\Message;
66
use Neos\Flow\Mvc\Controller\ActionController;
7+
use Neos\Flow\Security\Context;
78
use Yeebase\TwoFactorAuthentication\Service\TwoFactorAuthenticationService;
89

910
abstract class AbstractTwoFactorAuthenticationManagementController extends ActionController
1011
{
1112

13+
/**
14+
* @var Context
15+
* @Flow\Inject
16+
*/
17+
protected $securityContext;
18+
1219
/**
1320
* @var TwoFactorAuthenticationService
1421
* @Flow\Inject
@@ -32,9 +39,9 @@ public function enableAction(string $secret)
3239

3340
if ($this->twoFactorAuthenticationService->validateSecret($secret, $account, true)) {
3441
$this->twoFactorAuthenticationService->enableTwoFactorAuthentication($account);
35-
$this->addFlashMessage('Zwei-Faktor-Authentisierung aktiviert.');
42+
$this->addFlashMessage('Two-Factor-Authentication activated.', '', Message::SEVERITY_OK, [], 1511944292);
3643
} else {
37-
$this->addFlashMessage('Falsches Secret.', Message::SEVERITY_ERROR);
44+
$this->addFlashMessage('Wrong Secret.', '', Message::SEVERITY_ERROR, [], 1511944293);
3845
}
3946

4047
$this->redirect('configure');
@@ -46,9 +53,9 @@ public function disableAction(string $secret)
4653

4754
if ($this->twoFactorAuthenticationService->validateSecret($secret, $account)) {
4855
$this->twoFactorAuthenticationService->disableTwoFactorAuthentication($account);
49-
$this->addFlashMessage('Zwei-Faktor-Authentisierung deaktiviert.');
56+
$this->addFlashMessage('Two-Factor-Authentication deactivated.', '', Message::SEVERITY_OK, [], 1511944294);
5057
} else {
51-
$this->addFlashMessage('Falsches Secret.', Message::SEVERITY_ERROR);
58+
$this->addFlashMessage('Wrong Secret.', '', Message::SEVERITY_ERROR, [], 1511944293);
5259
}
5360

5461
$this->redirect('configure');

Classes/Service/TwoFactorAuthenticationService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ protected function setupTwoFactorAuthenticationCredentials(Account $account)
116116
$this->setTwoFactorAuthenticationCredentials($account, $credentials);
117117
}
118118

119-
protected function getTwoFactorAuthenticationCredentials(Account $account): TwoFactorAuthenticationCredentialsSource
119+
protected function getTwoFactorAuthenticationCredentials(Account $account)
120120
{
121121
if (! $this->hasTwoFactorAuthenticationCredentials($account)) {
122122
throw new \Exception('Trying to access uninitialized Two-Factor-Authentication credentials.', 1511271518);

0 commit comments

Comments
 (0)