Fixed some inspection issues.

This commit is contained in:
Jan Böhmer 2020-01-04 20:14:42 +01:00
parent 5f27abd8f3
commit 1aed1d1d26
15 changed files with 14 additions and 47 deletions

View file

@ -21,24 +21,16 @@
namespace App\Controller; namespace App\Controller;
use App\Entity\Parts\Part;
use App\Entity\UserSystem\U2FKey;
use App\Entity\UserSystem\User;
use App\Services\PasswordResetManager; use App\Services\PasswordResetManager;
use App\Services\TFA\BackupCodeManager;
use Doctrine\ORM\EntityManagerInterface;
use Gregwar\CaptchaBundle\Type\CaptchaType; use Gregwar\CaptchaBundle\Type\CaptchaType;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\PasswordType; use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType; use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils; use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
use Symfony\Component\Validator\Constraints\Length; use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\NotBlank;
@ -78,11 +70,11 @@ class SecurityController extends AbstractController
public function requestPwReset(PasswordResetManager $passwordReset, Request $request) 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!"); throw new AccessDeniedHttpException('The password reset via email is disabled!');
} }
if ($this->isGranted('IS_AUTHENTICATED_REMEMBERED')) { if ($this->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
throw new AccessDeniedHttpException("You are already logged in, so you can not reset your password!"); throw new AccessDeniedHttpException('You are already logged in, so you can not reset your password!');
} }
$builder = $this->createFormBuilder(); $builder = $this->createFormBuilder();
@ -119,11 +111,11 @@ class SecurityController extends AbstractController
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!"); throw new AccessDeniedHttpException('The password reset via email is disabled!');
} }
if ($this->isGranted('IS_AUTHENTICATED_REMEMBERED')) { if ($this->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
throw new AccessDeniedHttpException("You are already logged in, so you can not reset your password!"); throw new AccessDeniedHttpException('You are already logged in, so you can not reset your password!');
} }
$data = ['username' => $user, 'token' => $token]; $data = ['username' => $user, 'token' => $token];

View file

@ -27,10 +27,7 @@ use App\Entity\Parts\Footprint;
use App\Entity\Parts\Manufacturer; use App\Entity\Parts\Manufacturer;
use App\Entity\Parts\Storelocation; use App\Entity\Parts\Storelocation;
use App\Entity\Parts\Supplier; use App\Entity\Parts\Supplier;
use App\Entity\UserSystem\U2FKey;
use App\Entity\UserSystem\User;
use App\Services\Trees\ToolsTreeBuilder; use App\Services\Trees\ToolsTreeBuilder;
use App\Services\Trees\NodesListBuilder;
use App\Services\Trees\TreeViewGenerator; use App\Services\Trees\TreeViewGenerator;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;

View file

@ -25,29 +25,16 @@ use App\Entity\Attachments\AttachmentType;
use App\Entity\Attachments\UserAttachment; use App\Entity\Attachments\UserAttachment;
use App\Entity\UserSystem\User; use App\Entity\UserSystem\User;
use App\Form\Permissions\PermissionsType; use App\Form\Permissions\PermissionsType;
use App\Form\TFAGoogleSettingsType;
use App\Form\UserAdminForm; use App\Form\UserAdminForm;
use App\Form\UserSettingsType;
use App\Services\EntityExporter; use App\Services\EntityExporter;
use App\Services\EntityImporter; use App\Services\EntityImporter;
use App\Services\StructuralElementRecursionHelper; use App\Services\StructuralElementRecursionHelper;
use App\Services\TFA\BackupCodeManager;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use \Exception;
use Scheb\TwoFactorBundle\Security\TwoFactor\Provider\Google\GoogleAuthenticator;
use Symfony\Component\Asset\Packages; use Symfony\Component\Asset\Packages;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Component\Validator\Constraints\Length;
/** /**
* @Route("/user") * @Route("/user")

View file

@ -70,7 +70,7 @@ class UserSettingsController extends AbstractController
if (empty($user->getBackupCodes())) { if (empty($user->getBackupCodes())) {
$this->addFlash('error', 'tfa_backup.no_codes_enabled'); $this->addFlash('error', 'tfa_backup.no_codes_enabled');
throw new Exception('You do not have any backup codes enabled, therefore you can not view them!'); throw new \RuntimeException('You do not have any backup codes enabled, therefore you can not view them!');
} }
return $this->render('Users/backup_codes.html.twig', [ return $this->render('Users/backup_codes.html.twig', [
@ -253,7 +253,7 @@ class UserSettingsController extends AbstractController
} }
$google_form->handleRequest($request); $google_form->handleRequest($request);
if($google_form->isSubmitted() && $google_form->isValid() && !$this->demo_mode) { if ($google_form->isSubmitted() && $google_form->isValid() && !$this->demo_mode) {
if (!$google_enabled) { if (!$google_enabled) {
//Save 2FA settings (save secrets) //Save 2FA settings (save secrets)
$user->setGoogleAuthenticatorSecret($google_form->get('googleAuthenticatorSecret')->getData()); $user->setGoogleAuthenticatorSecret($google_form->get('googleAuthenticatorSecret')->getData());
@ -261,7 +261,9 @@ class UserSettingsController extends AbstractController
$em->flush(); $em->flush();
$this->addFlash('success', 'user.settings.2fa.google.activated'); $this->addFlash('success', 'user.settings.2fa.google.activated');
return $this->redirectToRoute('user_settings'); return $this->redirectToRoute('user_settings');
} elseif ($google_enabled) { }
if ($google_enabled) {
//Remove secret to disable google authenticator //Remove secret to disable google authenticator
$user->setGoogleAuthenticatorSecret(null); $user->setGoogleAuthenticatorSecret(null);
$backupCodeManager->disableBackupCodesIfUnused($user); $backupCodeManager->disableBackupCodesIfUnused($user);

View file

@ -24,7 +24,6 @@ declare(strict_types=1);
namespace App\Entity\Attachments; namespace App\Entity\Attachments;
use App\Entity\Base\NamedDBElement; use App\Entity\Base\NamedDBElement;
use App\Entity\Parts\Category;
use App\Validator\Constraints\Selectable; use App\Validator\Constraints\Selectable;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;

View file

@ -22,7 +22,6 @@
namespace App\Entity\Base; namespace App\Entity\Base;
use App\Entity\Attachments\Attachment; use App\Entity\Attachments\Attachment;
use App\Entity\Parts\Part;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
/** /**

View file

@ -133,7 +133,8 @@ class Device extends PartsContainingDBElement
/** /**
* Set the order quantity. * Set the order quantity.
* *
* @param int $new_order_quantity the new order quantity * @param int $new_order_quantity the new order quantity
* @return $this
*/ */
public function setOrderQuantity(int $new_order_quantity): self public function setOrderQuantity(int $new_order_quantity): self
{ {

View file

@ -53,7 +53,6 @@ namespace App\Entity\Parts;
use App\Entity\Attachments\Attachment; use App\Entity\Attachments\Attachment;
use App\Entity\Attachments\AttachmentContainingDBElement; use App\Entity\Attachments\AttachmentContainingDBElement;
use App\Entity\Base\MasterAttachmentTrait;
use App\Entity\Devices\Device; use App\Entity\Devices\Device;
use App\Entity\Parts\PartTraits\AdvancedPropertyTrait; use App\Entity\Parts\PartTraits\AdvancedPropertyTrait;
use App\Entity\Parts\PartTraits\BasicPropertyTrait; use App\Entity\Parts\PartTraits\BasicPropertyTrait;

View file

@ -112,6 +112,7 @@ class PartLot extends DBElement
* This is the case, if the expiration date is greater the the current date. * This is the case, if the expiration date is greater the the current date.
* *
* @return bool|null True, if the part lot is expired. Returns null, if no expiration date was set. * @return bool|null True, if the part lot is expired. Returns null, if no expiration date was set.
* @throws \Exception If an error with the DateTime occurs
*/ */
public function isExpired(): ?bool public function isExpired(): ?bool
{ {

View file

@ -23,7 +23,6 @@ namespace App\Entity\Parts\PartTraits;
use App\Entity\Parts\Category; use App\Entity\Parts\Category;
use App\Entity\Parts\Footprint; use App\Entity\Parts\Footprint;
use App\Entity\Parts\Part;
use App\Security\Annotations\ColumnSecurity; use App\Security\Annotations\ColumnSecurity;
use App\Validator\Constraints\Selectable; use App\Validator\Constraints\Selectable;

View file

@ -21,7 +21,6 @@
namespace App\Entity\Parts\PartTraits; namespace App\Entity\Parts\PartTraits;
use App\Entity\Parts\Part;
use App\Entity\PriceInformations\Orderdetail; use App\Entity\PriceInformations\Orderdetail;
use App\Security\Annotations\ColumnSecurity; use App\Security\Annotations\ColumnSecurity;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;

View file

@ -770,8 +770,9 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
/** /**
* Set the backup codes for this user. Existing backup codes are overridden. * Set the backup codes for this user. Existing backup codes are overridden.
* @param string[] $codes A * @param string[] $codes An array containing the backup codes
* @return $this * @return $this
* @throws \Exception If an error with the datetime occurs
*/ */
public function setBackupCodes(array $codes) : self public function setBackupCodes(array $codes) : self
{ {

View file

@ -23,10 +23,8 @@ namespace App\Repository;
use App\Entity\Base\NamedDBElement; use App\Entity\Base\NamedDBElement;
use App\Entity\Base\StructuralDBElement;
use App\Helpers\Trees\TreeViewNode; use App\Helpers\Trees\TreeViewNode;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Mapping\Entity;
class NamedDBElementRepository extends EntityRepository class NamedDBElementRepository extends EntityRepository

View file

@ -24,8 +24,6 @@ namespace App\Repository;
use App\Entity\Base\StructuralDBElement; use App\Entity\Base\StructuralDBElement;
use App\Helpers\Trees\StructuralDBElementIterator; use App\Helpers\Trees\StructuralDBElementIterator;
use App\Helpers\Trees\TreeViewNode; use App\Helpers\Trees\TreeViewNode;
use Doctrine\ORM\EntityRepository;
use Symfony\Component\Stopwatch\Stopwatch;
class StructuralDBElementRepository extends NamedDBElementRepository class StructuralDBElementRepository extends NamedDBElementRepository
{ {

View file

@ -22,12 +22,7 @@
namespace App\Repository; namespace App\Repository;
use App\Entity\UserSystem\User; use App\Entity\UserSystem\User;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Mapping;
use Doctrine\ORM\NonUniqueResultException; use Doctrine\ORM\NonUniqueResultException;
use Symfony\Bridge\Doctrine\RegistryInterface;
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface; use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\User\UserInterface;