Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2fa login #3580

Open
wants to merge 57 commits into
base: fork6
Choose a base branch
from
Open

2fa login #3580

wants to merge 57 commits into from

Conversation

bjorvack
Copy link
Contributor

Type

  • Enhancement
  • Feature

Resolves the following issues

Adds 2FA login

@bjorvack bjorvack requested a review from a team as a code owner November 24, 2023 09:23
src/Core/Domain/Form/TogglePasswordInputType.php Outdated Show resolved Hide resolved
@@ -156,6 +156,8 @@ private function determineDefaultTranslationDomain(): TranslationDomain
return match ($mainRequest->get('_route')) {
'backend_action',
'backend_login' => ActionSlug::fromRequest($mainRequest)->getTranslationDomain(),
'backend_2fa_login' => ActionSlug::fromRequest($mainRequest)->getTranslationDomain(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use the fallback, so just add them to the comma list with backend_action and backend_login

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you clarify what you mean

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is exactly the same as for backend_action and backend_login, so you can just include them in that comma separated list

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed 1f2271c

src/Modules/Backend/Backend/Actions/ModuleSettings.php Outdated Show resolved Hide resolved
return parent::form($request);
}

protected function getTemplateVars(Request $request, TwoFactorTokenInterface $token): array
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: update the code here in my own branch with changes (I've made this more generic and easy to add extra controllers)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bjorvack this code has already landed, you only need to set the things specific for your controller all those others should already be there

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed d3e8501

@carakas
Copy link
Member

carakas commented Nov 24, 2023

You'll also need to fix the tests and add tests for 2FA

Copy link
Member

@carakas carakas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests are still failing
A little bit of extra feedback
Can you rebase your code?

) {
}

public function __invoke(ChangeModuleSettings $changeModuleSettings): void
{
$this->moduleRepository->save($changeModuleSettings->module);
$this->moduleSettings->invalidateCache();
$this->commandBus->dispatch(new ClearContainerCache());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use $this->eventDispatcher->dispatch(new ClearCacheEvent()); instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed 7ef40cf

@@ -156,6 +156,8 @@ private function determineDefaultTranslationDomain(): TranslationDomain
return match ($mainRequest->get('_route')) {
'backend_action',
'backend_login' => ActionSlug::fromRequest($mainRequest)->getTranslationDomain(),
'backend_2fa_login' => ActionSlug::fromRequest($mainRequest)->getTranslationDomain(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is exactly the same as for backend_action and backend_login, so you can just include them in that comma separated list

validCallback: function (FormInterface $form): Response {
$this->commandBus->dispatch($form->getData());

if (!$this->moduleSettings->get(ModuleName::fromString('Backend'), '2fa_enabled', false)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this also belong in the command? Otherwise if the command is used somewhere else this code won't be executed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed cd1ac62

);
}

#[Route('/2fa', name: 'backend_2fa_login')]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this route be /private/2fa?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed 8ad6b65

return parent::form($request);
}

protected function getTemplateVars(Request $request, TwoFactorTokenInterface $token): array
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bjorvack this code has already landed, you only need to set the things specific for your controller all those others should already be there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants