mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-28 12:40:08 +02:00
Applied code style rules to src/
This commit is contained in:
parent
700c049d26
commit
f861de791f
186 changed files with 1462 additions and 1059 deletions
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -41,7 +44,7 @@ class LoginSuccessListener implements EventSubscriberInterface
|
|||
$this->flashBag = $flashBag;
|
||||
}
|
||||
|
||||
public function onLogin(InteractiveLoginEvent $event)
|
||||
public function onLogin(InteractiveLoginEvent $event): void
|
||||
{
|
||||
$this->flashBag->add('notice', $this->translator->trans('flash.login_successful'));
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -43,7 +46,7 @@ class LogoutOnDisabledUserListener implements EventSubscriberInterface
|
|||
$this->urlGenerator = $urlGenerator;
|
||||
}
|
||||
|
||||
public function onRequest(RequestEvent $event)
|
||||
public function onRequest(RequestEvent $event): void
|
||||
{
|
||||
$user = $this->security->getUser();
|
||||
if ($user instanceof User && $user->isDisabled()) {
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -36,10 +39,6 @@ use Symfony\Component\Security\Http\HttpUtils;
|
|||
*/
|
||||
class PasswordChangeNeededSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
protected $security;
|
||||
protected $flashBag;
|
||||
protected $httpUtils;
|
||||
|
||||
/**
|
||||
* @var string[] The routes the user is allowed to access without being redirected.
|
||||
* This should be only routes related to login/logout and user settings
|
||||
|
@ -54,6 +53,9 @@ class PasswordChangeNeededSubscriber implements EventSubscriberInterface
|
|||
|
||||
/** @var string The route the user will redirected to, if he needs to change this password */
|
||||
public const REDIRECT_TARGET = 'user_settings';
|
||||
protected $security;
|
||||
protected $flashBag;
|
||||
protected $httpUtils;
|
||||
|
||||
public function __construct(Security $security, FlashBagInterface $flashBag, HttpUtils $httpUtils)
|
||||
{
|
||||
|
@ -72,15 +74,15 @@ class PasswordChangeNeededSubscriber implements EventSubscriberInterface
|
|||
$user = $this->security->getUser();
|
||||
$request = $event->getRequest();
|
||||
|
||||
if (!$event->isMasterRequest()) {
|
||||
if (! $event->isMasterRequest()) {
|
||||
return;
|
||||
}
|
||||
if (!$user instanceof User) {
|
||||
if (! $user instanceof User) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Abort if we dont need to redirect the user.
|
||||
if (!$user->isNeedPwChange() && !static::TFARedirectNeeded($user)) {
|
||||
if (! $user->isNeedPwChange() && ! static::TFARedirectNeeded($user)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -123,16 +125,13 @@ class PasswordChangeNeededSubscriber implements EventSubscriberInterface
|
|||
{
|
||||
$tfa_enabled = $user->isU2FAuthEnabled() || $user->isGoogleAuthenticatorEnabled();
|
||||
|
||||
if (null !== $user->getGroup() && $user->getGroup()->isEnforce2FA() && !$tfa_enabled) {
|
||||
if (null !== $user->getGroup() && $user->getGroup()->isEnforce2FA() && ! $tfa_enabled) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return [
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -57,9 +60,9 @@ class SymfonyDebugToolbarSubscriber implements EventSubscriberInterface
|
|||
return ['kernel.response' => 'onKernelResponse'];
|
||||
}
|
||||
|
||||
public function onKernelResponse(FilterResponseEvent $event)
|
||||
public function onKernelResponse(FilterResponseEvent $event): void
|
||||
{
|
||||
if (!$this->kernel->getParameter('kernel.debug')) {
|
||||
if (! $this->kernel->getParameter('kernel.debug')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -41,18 +44,18 @@ class TimezoneListener implements EventSubscriberInterface
|
|||
$this->security = $security;
|
||||
}
|
||||
|
||||
public function setTimeZone(ControllerEvent $event)
|
||||
public function setTimeZone(ControllerEvent $event): void
|
||||
{
|
||||
$timezone = null;
|
||||
|
||||
//Check if the user has set a timezone
|
||||
$user = $this->security->getUser();
|
||||
if ($user instanceof User && !empty($user->getTimezone())) {
|
||||
if ($user instanceof User && ! empty($user->getTimezone())) {
|
||||
$timezone = $user->getTimezone();
|
||||
}
|
||||
|
||||
//Fill with default value if needed
|
||||
if (null === $timezone && !empty($this->default_timezone)) {
|
||||
if (null === $timezone && ! empty($this->default_timezone)) {
|
||||
$timezone = $this->default_timezone;
|
||||
}
|
||||
|
||||
|
|
|
@ -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,13 +34,12 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
|||
|
||||
class U2FRegistrationSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
/** @var UrlGeneratorInterface */
|
||||
private $router;
|
||||
|
||||
protected $em;
|
||||
|
||||
protected $demo_mode;
|
||||
protected $flashBag;
|
||||
/** @var UrlGeneratorInterface */
|
||||
private $router;
|
||||
|
||||
public function __construct(UrlGeneratorInterface $router, EntityManagerInterface $entityManager, FlashBagInterface $flashBag, bool $demo_mode)
|
||||
{
|
||||
|
@ -58,7 +60,7 @@ class U2FRegistrationSubscriber implements EventSubscriberInterface
|
|||
public function onRegister(RegisterEvent $event): void
|
||||
{
|
||||
//Skip adding of U2F key on demo mode
|
||||
if (!$this->demo_mode) {
|
||||
if (! $this->demo_mode) {
|
||||
$user = $event->getUser();
|
||||
$registration = $event->getRegistration();
|
||||
$newKey = new U2FKey();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue