Applied code style rules to src/

This commit is contained in:
Jan Böhmer 2020-01-05 15:46:58 +01:00
parent 700c049d26
commit f861de791f
186 changed files with 1462 additions and 1059 deletions

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -80,7 +83,7 @@ abstract class BaseAdminController extends AbstractController
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
//Check if we editing a user and if we need to change the password of it
if ($entity instanceof User && !empty($form['new_password']->getData())) {
if ($entity instanceof User && ! empty($form['new_password']->getData())) {
$password = $this->passwordEncoder->encodePassword($entity, $form['new_password']->getData());
$entity->setPassword($password);
//By default the user must change the password afterwards
@ -90,11 +93,12 @@ abstract class BaseAdminController extends AbstractController
//Upload passed files
$attachments = $form['attachments'];
foreach ($attachments as $attachment) {
/** @var $attachment FormInterface */
/** @var FormInterface $attachment */
$options = [
'secure_attachment' => $attachment['secureFile']->getData(),
'download_url' => $attachment['downloadURL']->getData(),
];
try {
$this->attachmentSubmitHandler->handleFormSubmit($attachment->getData(), $attachment['file']->getData(), $options);
} catch (AttachmentDownloadException $ex) {
@ -112,7 +116,7 @@ abstract class BaseAdminController extends AbstractController
//Rebuild form, so it is based on the updated data. Important for the parent field!
//We can not use dynamic form events here, because the parent entity list is build from database!
$form = $this->createForm($this->form_class, $entity, ['attachment_class' => $this->attachment_class]);
} elseif ($form->isSubmitted() && !$form->isValid()) {
} elseif ($form->isSubmitted() && ! $form->isValid()) {
$this->addFlash('error', 'entity.edit_flash.invalid');
}
@ -136,7 +140,7 @@ abstract class BaseAdminController extends AbstractController
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
if ($new_entity instanceof User && !empty($form['new_password']->getData())) {
if ($new_entity instanceof User && ! empty($form['new_password']->getData())) {
$password = $this->passwordEncoder->encodePassword($new_entity, $form['new_password']->getData());
$new_entity->setPassword($password);
//By default the user must change the password afterwards
@ -146,11 +150,12 @@ abstract class BaseAdminController extends AbstractController
//Upload passed files
$attachments = $form['attachments'];
foreach ($attachments as $attachment) {
/** @var $attachment FormInterface */
/** @var FormInterface $attachment */
$options = [
'secure_attachment' => $attachment['secureFile']->getData(),
'download_url' => $attachment['downloadURL']->getData(),
];
try {
$this->attachmentSubmitHandler->handleFormSubmit($attachment->getData(), $attachment['file']->getData(), $options);
} catch (AttachmentDownloadException $ex) {
@ -168,7 +173,7 @@ abstract class BaseAdminController extends AbstractController
return $this->redirectToRoute($this->route_base.'_edit', ['id' => $new_entity->getID()]);
}
if ($form->isSubmitted() && !$form->isValid()) {
if ($form->isSubmitted() && ! $form->isValid()) {
$this->addFlash('error', 'entity.created_flash.invalid');
}
@ -187,7 +192,7 @@ abstract class BaseAdminController extends AbstractController
$errors = $importer->fileToDBEntities($file, $this->entity_class, $options);
foreach ($errors as $name => $error) {
/* @var $error ConstraintViolationList */
/** @var ConstraintViolationList $error */
$this->addFlash('error', $name.':'.$error);
}
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -32,7 +35,6 @@ use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\SerializerInterface;
/**
* @Route("/footprint")
@ -76,8 +78,6 @@ class FootprintController extends BaseAdminController
/**
* @Route("/export", name="footprint_export_all")
*
* @param SerializerInterface $serializer
*
* @return Response
*/
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -32,7 +35,6 @@ use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\SerializerInterface;
/**
* @Route("/manufacturer")
@ -76,8 +78,6 @@ class ManufacturerController extends BaseAdminController
/**
* @Route("/export", name="manufacturer_export_all")
*
* @param SerializerInterface $serializer
*
* @return Response
*/
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -32,7 +35,6 @@ use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\SerializerInterface;
/**
* @Route("/measurement_unit")
@ -76,8 +78,6 @@ class MeasurementUnitController extends BaseAdminController
/**
* @Route("/export", name="measurement_unit_export_all")
*
* @param SerializerInterface $serializer
*
* @return Response
*/
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -31,7 +34,6 @@ use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\SerializerInterface;
/**
* @Route("/store_location")
@ -75,8 +77,6 @@ class StorelocationController extends BaseAdminController
/**
* @Route("/export", name="store_location_export_all")
*
* @param SerializerInterface $serializer
*
* @return Response
*/
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -31,7 +34,6 @@ use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\SerializerInterface;
/**
* @Route("/supplier")
@ -75,8 +77,6 @@ class SupplierController extends BaseAdminController
/**
* @Route("/export", name="supplier_export_all")
*
* @param SerializerInterface $serializer
*
* @return Response
*/
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -49,7 +52,7 @@ class AttachmentFileController extends AbstractController
throw new \RuntimeException('You can not download external attachments!');
}
if (!$helper->isFileExisting($attachment)) {
if (! $helper->isFileExisting($attachment)) {
throw new \RuntimeException('The file associated with the attachment is not existing!');
}
@ -79,7 +82,7 @@ class AttachmentFileController extends AbstractController
throw new \RuntimeException('You can not download external attachments!');
}
if (!$helper->isFileExisting($attachment)) {
if (! $helper->isFileExisting($attachment)) {
throw new \RuntimeException('The file associated with the attachment is not existing!');
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -80,11 +82,12 @@ class PartController extends AbstractController
//Upload passed files
$attachments = $form['attachments'];
foreach ($attachments as $attachment) {
/** @var $attachment FormInterface */
/** @var FormInterface $attachment */
$options = [
'secure_attachment' => $attachment['secureFile']->getData(),
'download_url' => $attachment['downloadURL']->getData(),
];
try {
$attachmentSubmitHandler->handleFormSubmit($attachment->getData(), $attachment['file']->getData(), $options);
} catch (AttachmentDownloadException $ex) {
@ -100,7 +103,7 @@ class PartController extends AbstractController
$this->addFlash('info', 'part.edited_flash');
//Reload form, so the SIUnitType entries use the new part unit
$form = $this->createForm(PartBaseType::class, $part);
} elseif ($form->isSubmitted() && !$form->isValid()) {
} elseif ($form->isSubmitted() && ! $form->isValid()) {
$this->addFlash('error', 'part.edited_flash.invalid');
}
@ -163,11 +166,12 @@ class PartController extends AbstractController
//Upload passed files
$attachments = $form['attachments'];
foreach ($attachments as $attachment) {
/** @var $attachment FormInterface */
/** @var FormInterface $attachment */
$options = [
'secure_attachment' => $attachment['secureFile']->getData(),
'download_url' => $attachment['downloadURL']->getData(),
];
try {
$attachmentSubmitHandler->handleFormSubmit($attachment->getData(), $attachment['file']->getData(), $options);
} catch (AttachmentDownloadException $ex) {
@ -185,7 +189,7 @@ class PartController extends AbstractController
return $this->redirectToRoute('part_edit', ['id' => $new_part->getID()]);
}
if ($form->isSubmitted() && !$form->isValid()) {
if ($form->isSubmitted() && ! $form->isValid()) {
$this->addFlash('error', 'part.created_flash.invalid');
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -37,8 +40,6 @@ class PartListsController extends AbstractController
/**
* @Route("/category/{id}/parts", name="part_list_category")
*
* @param $id int The id of the category
*
* @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\Response
*/
public function showCategory(Category $category, Request $request, DataTableFactory $dataTable)
@ -59,8 +60,6 @@ class PartListsController extends AbstractController
/**
* @Route("/footprint/{id}/parts", name="part_list_footprint")
*
* @param $id int The id of the category
*
* @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\Response
*/
public function showFootprint(Footprint $footprint, Request $request, DataTableFactory $dataTable)
@ -81,8 +80,6 @@ class PartListsController extends AbstractController
/**
* @Route("/manufacturer/{id}/parts", name="part_list_manufacturer")
*
* @param $id int The id of the category
*
* @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\Response
*/
public function showManufacturer(Manufacturer $manufacturer, Request $request, DataTableFactory $dataTable)
@ -103,8 +100,6 @@ class PartListsController extends AbstractController
/**
* @Route("/store_location/{id}/parts", name="part_list_store_location")
*
* @param $id int The id of the category
*
* @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\Response
*/
public function showStorelocation(Storelocation $storelocation, Request $request, DataTableFactory $dataTable)
@ -125,8 +120,6 @@ class PartListsController extends AbstractController
/**
* @Route("/supplier/{id}/parts", name="part_list_supplier")
*
* @param $id int The id of the category
*
* @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\Response
*/
public function showSupplier(Supplier $supplier, Request $request, DataTableFactory $dataTable)
@ -179,9 +172,9 @@ class PartListsController extends AbstractController
}
return $this->render('Parts/lists/search_list.html.twig', [
'datatable' => $table,
'keyword' => $search,
]);
'datatable' => $table,
'keyword' => $search,
]);
}
/**

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -55,7 +58,7 @@ class RedirectController extends AbstractController
//Check if a user has set a preferred language setting:
$user = $this->getUser();
if (($user instanceof User) && !empty($user->getLanguage())) {
if (($user instanceof User) && ! empty($user->getLanguage())) {
$locale = $user->getLanguage();
}
@ -63,7 +66,7 @@ class RedirectController extends AbstractController
$new_url = $request->getUriForPath('/'.$locale.$request->getPathInfo());
//If either mod_rewrite is not enabled or the index.php version is enforced, add index.php to the string
if (($this->enforce_index_php || !$this->checkIfModRewriteAvailable())
if (($this->enforce_index_php || ! $this->checkIfModRewriteAvailable())
&& false === strpos($new_url, 'index.php')) {
//Like Request::getUriForPath only with index.php
$new_url = $request->getSchemeAndHttpHost().$request->getBaseUrl().'/index.php/'.$locale.$request->getPathInfo();
@ -81,7 +84,7 @@ class RedirectController extends AbstractController
*/
public function checkIfModRewriteAvailable()
{
if (!\function_exists('apache_get_modules')) {
if (! \function_exists('apache_get_modules')) {
//If we can not check for apache modules, we just hope for the best and assume url rewriting is available
//If you want to enforce index.php versions of the url, you can override this via ENV vars.
return true;

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -69,7 +72,7 @@ class SecurityController extends AbstractController
*/
public function requestPwReset(PasswordResetManager $passwordReset, Request $request)
{
if (!$this->allow_email_pw_reset) {
if (! $this->allow_email_pw_reset) {
throw new AccessDeniedHttpException('The password reset via email is disabled!');
}
@ -109,9 +112,9 @@ class SecurityController extends AbstractController
/**
* @Route("/pw_reset/new_pw/{user}/{token}", name="pw_reset_new_pw")
*/
public function pwResetNewPw(PasswordResetManager $passwordReset, Request $request, string $user = null, string $token = null)
public function pwResetNewPw(PasswordResetManager $passwordReset, Request $request, ?string $user = null, ?string $token = null)
{
if (!$this->allow_email_pw_reset) {
if (! $this->allow_email_pw_reset) {
throw new AccessDeniedHttpException('The password reset via email is disabled!');
}
@ -149,7 +152,7 @@ class SecurityController extends AbstractController
$data = $form->getData();
//Try to set the new password
$success = $passwordReset->setNewPassword($data['username'], $data['token'], $data['new_password']);
if (!$success) {
if (! $success) {
$this->addFlash('error', 'pw_reset.new_pw.error');
} else {
$this->addFlash('success', 'pw_reset.new_pw.success');
@ -166,7 +169,7 @@ class SecurityController extends AbstractController
/**
* @Route("/logout", name="logout")
*/
public function logout()
public function logout(): void
{
throw new \RuntimeException('Will be intercepted before getting here');
}

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -61,7 +64,7 @@ class TreeController extends AbstractController
* @Route("/category/{id}", name="tree_category")
* @Route("/categories")
*/
public function categoryTree(Category $category = null)
public function categoryTree(?Category $category = null)
{
$tree = $this->treeGenerator->getTreeView(Category::class, $category);
@ -72,7 +75,7 @@ class TreeController extends AbstractController
* @Route("/footprint/{id}", name="tree_footprint")
* @Route("/footprints")
*/
public function footprintTree(Footprint $footprint = null)
public function footprintTree(?Footprint $footprint = null)
{
$tree = $this->treeGenerator->getTreeView(Footprint::class, $footprint);
@ -83,7 +86,7 @@ class TreeController extends AbstractController
* @Route("/location/{id}", name="tree_location")
* @Route("/locations")
*/
public function locationTree(Storelocation $location = null)
public function locationTree(?Storelocation $location = null)
{
$tree = $this->treeGenerator->getTreeView(Storelocation::class, $location);
@ -94,7 +97,7 @@ class TreeController extends AbstractController
* @Route("/manufacturer/{id}", name="tree_manufacturer")
* @Route("/manufacturers")
*/
public function manufacturerTree(Manufacturer $manufacturer = null)
public function manufacturerTree(?Manufacturer $manufacturer = null)
{
$tree = $this->treeGenerator->getTreeView(Manufacturer::class, $manufacturer);
@ -105,7 +108,7 @@ class TreeController extends AbstractController
* @Route("/supplier/{id}", name="tree_supplier")
* @Route("/suppliers")
*/
public function supplierTree(Supplier $supplier = null)
public function supplierTree(?Supplier $supplier = null)
{
$tree = $this->treeGenerator->getTreeView(Supplier::class, $supplier);
@ -116,7 +119,7 @@ class TreeController extends AbstractController
* @Route("/device/{id}", name="tree_device")
* @Route("/devices")
*/
public function deviceTree(Device $device = null)
public function deviceTree(?Device $device = null)
{
$tree = $this->treeGenerator->getTreeView(Device::class, $device, '');

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -34,7 +37,6 @@ use Symfony\Component\Asset\Packages;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\SerializerInterface;
/**
* @Route("/user")
@ -106,8 +108,6 @@ class UserController extends AdminPages\BaseAdminController
/**
* @Route("/export", name="user_export_all")
*
* @param SerializerInterface $serializer
*
* @return Response
*/
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)
@ -183,7 +183,7 @@ class UserController extends AdminPages\BaseAdminController
$url = 'https://www.gravatar.com/avatar/';
$url .= md5(strtolower(trim($email)));
$url .= "?s=$s&d=$d&r=$r";
$url .= "?s=${s}&d=${d}&r=${r}";
if ($img) {
$url = '<img src="'.$url.'"';
foreach ($atts as $key => $val) {

View file

@ -1,4 +1,7 @@
<?php
declare(strict_types=1);
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
@ -61,12 +64,13 @@ class UserSettingsController extends AbstractController
//When user change its settings, he should be logged in fully.
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
if (!$user instanceof User) {
if (! $user instanceof User) {
return new \RuntimeException('This controller only works only for Part-DB User objects!');
}
if (empty($user->getBackupCodes())) {
$this->addFlash('error', 'tfa_backup.no_codes_enabled');
throw new \RuntimeException('You do not have any backup codes enabled, therefore you can not view them!');
}
@ -91,7 +95,7 @@ class UserSettingsController extends AbstractController
//When user change its settings, he should be logged in fully.
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
if (!$user instanceof User) {
if (! $user instanceof User) {
throw new \RuntimeException('This controller only works only for Part-DB User objects!');
}
@ -103,12 +107,14 @@ class UserSettingsController extends AbstractController
$u2f = $key_repo->find($key_id);
if (null === $u2f) {
$this->addFlash('danger', 'tfa_u2f.u2f_delete.not_existing');
throw new \RuntimeException('Key not existing!');
}
//User can only delete its own U2F keys
if ($u2f->getUser() !== $user) {
$this->addFlash('danger', 'tfa_u2f.u2f_delete.access_denied');
throw new \RuntimeException('You can only delete your own U2F keys!');
}
@ -138,7 +144,7 @@ class UserSettingsController extends AbstractController
//When user change its settings, he should be logged in fully.
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
if (!$user instanceof User) {
if (! $user instanceof User) {
return new \RuntimeException('This controller only works only for Part-DB User objects!');
}
@ -158,9 +164,7 @@ class UserSettingsController extends AbstractController
*/
public function userSettings(Request $request, EntityManagerInterface $em, UserPasswordEncoderInterface $passwordEncoder, GoogleAuthenticator $googleAuthenticator, BackupCodeManager $backupCodeManager)
{
/**
* @var User
*/
/** @var User */
$user = $this->getUser();
$page_need_reload = false;
@ -168,7 +172,7 @@ class UserSettingsController extends AbstractController
//When user change its settings, he should be logged in fully.
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
if (!$user instanceof User) {
if (! $user instanceof User) {
throw new \RuntimeException('This controller only works only for Part-DB User objects!');
}
@ -180,7 +184,7 @@ class UserSettingsController extends AbstractController
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid() && !$this->demo_mode) {
if ($form->isSubmitted() && $form->isValid() && ! $this->demo_mode) {
//Check if user theme setting has changed
if ($user->getTheme() !== $em->getUnitOfWork()->getOriginalEntityData($user)['theme']) {
$page_need_reload = true;
@ -217,9 +221,9 @@ class UserSettingsController extends AbstractController
'attr' => ['autocomplete' => 'new-password'],
],
'constraints' => [new Length([
'min' => 6,
'max' => 128,
])],
'min' => 6,
'max' => 128,
])],
])
->add('submit', SubmitType::class, ['label' => 'save'])
->getForm();
@ -227,7 +231,7 @@ class UserSettingsController extends AbstractController
$pw_form->handleRequest($request);
//Check if password if everything was correct, then save it to User and DB
if ($pw_form->isSubmitted() && $pw_form->isValid() && !$this->demo_mode) {
if ($pw_form->isSubmitted() && $pw_form->isValid() && ! $this->demo_mode) {
$password = $passwordEncoder->encodePassword($user, $pw_form['new_password']->getData());
$user->setPassword($password);
@ -242,14 +246,14 @@ class UserSettingsController extends AbstractController
//Handle 2FA things
$google_form = $this->createForm(TFAGoogleSettingsType::class, $user);
$google_enabled = $user->isGoogleAuthenticatorEnabled();
if (!$form->isSubmitted() && !$google_enabled) {
if (! $form->isSubmitted() && ! $google_enabled) {
$user->setGoogleAuthenticatorSecret($googleAuthenticator->generateSecret());
$google_form->get('googleAuthenticatorSecret')->setData($user->getGoogleAuthenticatorSecret());
}
$google_form->handleRequest($request);
if ($google_form->isSubmitted() && $google_form->isValid() && !$this->demo_mode) {
if (!$google_enabled) {
if ($google_form->isSubmitted() && $google_form->isValid() && ! $this->demo_mode) {
if (! $google_enabled) {
//Save 2FA settings (save secrets)
$user->setGoogleAuthenticatorSecret($google_form->get('googleAuthenticatorSecret')->getData());
$backupCodeManager->enableBackupCodes($user);
@ -277,7 +281,7 @@ class UserSettingsController extends AbstractController
])->getForm();
$backup_form->handleRequest($request);
if ($backup_form->isSubmitted() && $backup_form->isValid() && !$this->demo_mode) {
if ($backup_form->isSubmitted() && $backup_form->isValid() && ! $this->demo_mode) {
$backupCodeManager->regenerateBackupCodes($user);
$em->flush();
$this->addFlash('success', 'user.settings.2fa.backup_codes.regenerated');