Skip to content

2fa login#3580

Open
bjorvack wants to merge 57 commits intofork6from
2fa-login
Open

2fa login#3580
bjorvack wants to merge 57 commits intofork6from
2fa-login

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
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

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?

{
$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

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.

2 participants