mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-14 20:35:08 +02:00
Added an basic form to add Google Authenticator.
This commit is contained in:
parent
24672a30b9
commit
35b5640627
10 changed files with 277 additions and 3 deletions
42
src/Form/TFASettingsType.php
Normal file
42
src/Form/TFASettingsType.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
|
||||
use App\Entity\UserSystem\User;
|
||||
use App\Validator\Constraints\ValidGoogleAuthCode;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ResetType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class TFASettingsType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('google_confirmation', TextType::class, [
|
||||
'mapped' => false,
|
||||
'attr' => ['maxlength' => '6', 'minlength' => '6', 'pattern' => '\d*'],
|
||||
'constraints' => [new ValidGoogleAuthCode()]
|
||||
]);
|
||||
|
||||
$builder->add('googleAuthenticatorSecret', HiddenType::class,[
|
||||
'disabled' => false,
|
||||
]);
|
||||
|
||||
|
||||
$builder->add('submit', SubmitType::class);
|
||||
$builder->add('cancel', ResetType::class);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => User::class,
|
||||
]);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue