mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-24 18:58:46 +02:00
Added infos about 2FA and possibilities to disable them all on user admin page.
This commit is contained in:
parent
b5e80ec1b7
commit
b4958cbaf8
5 changed files with 106 additions and 11 deletions
|
@ -67,6 +67,29 @@ class UserController extends AdminPages\BaseAdminController
|
|||
*/
|
||||
public function edit(User $entity, Request $request, EntityManagerInterface $em)
|
||||
{
|
||||
//Handle 2FA disabling
|
||||
|
||||
if($request->request->has('reset_2fa')) {
|
||||
//Check if the admin has the needed permissions
|
||||
$this->denyAccessUnlessGranted('set_password', $entity);
|
||||
if ($this->isCsrfTokenValid('reset_2fa'.$entity->getId(), $request->request->get('_token'))) {
|
||||
//Disable Google authenticator
|
||||
$entity->setGoogleAuthenticatorSecret(null);
|
||||
$entity->setBackupCodes([]);
|
||||
//Remove all U2F keys
|
||||
foreach($entity->getU2FKeys() as $key) {
|
||||
$em->remove($key);
|
||||
}
|
||||
//Invalidate trusted devices
|
||||
$entity->invalidateTrustedDeviceTokens();
|
||||
$em->flush();
|
||||
|
||||
$this->addFlash('success', 'user.edit.reset_success');
|
||||
} else {
|
||||
$this->addFlash('danger', 'csfr_invalid');
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_edit($entity, $request, $em);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ use App\Services\MoneyFormatter;
|
|||
use App\Services\SIFormatter;
|
||||
use App\Services\TreeBuilder;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\TwigFilter;
|
||||
use Twig\TwigFunction;
|
||||
|
@ -49,13 +50,14 @@ class AppExtension extends AbstractExtension
|
|||
protected $amountFormatter;
|
||||
protected $attachmentURLGenerator;
|
||||
protected $FAIconGenerator;
|
||||
protected $translator;
|
||||
|
||||
public function __construct(EntityURLGenerator $entityURLGenerator, MarkdownParser $markdownParser,
|
||||
SerializerInterface $serializer, TreeBuilder $treeBuilder,
|
||||
MoneyFormatter $moneyFormatter,
|
||||
SIFormatter $SIFormatter, AmountFormatter $amountFormatter,
|
||||
AttachmentURLGenerator $attachmentURLGenerator,
|
||||
FAIconGenerator $FAIconGenerator)
|
||||
SerializerInterface $serializer, TreeBuilder $treeBuilder,
|
||||
MoneyFormatter $moneyFormatter,
|
||||
SIFormatter $SIFormatter, AmountFormatter $amountFormatter,
|
||||
AttachmentURLGenerator $attachmentURLGenerator,
|
||||
FAIconGenerator $FAIconGenerator, TranslatorInterface $translator)
|
||||
{
|
||||
$this->entityURLGenerator = $entityURLGenerator;
|
||||
$this->markdownParser = $markdownParser;
|
||||
|
@ -66,6 +68,7 @@ class AppExtension extends AbstractExtension
|
|||
$this->amountFormatter = $amountFormatter;
|
||||
$this->attachmentURLGenerator = $attachmentURLGenerator;
|
||||
$this->FAIconGenerator = $FAIconGenerator;
|
||||
$this->translator = $translator;
|
||||
}
|
||||
|
||||
public function getFilters()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue