mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-30 05:24:28 +02:00
Added an PHP CS fixer config file and applied it to files.
We now use the same the same style as the symfony project, and it allows us to simply fix the style by executing php_cs_fixer fix in the project root.
This commit is contained in:
parent
89258bc102
commit
e557bdedd5
210 changed files with 2099 additions and 2742 deletions
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
|
@ -17,18 +17,14 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Validator\Constraints;
|
||||
|
||||
|
||||
use App\Entity\UserSystem\Group;
|
||||
use App\Entity\UserSystem\User;
|
||||
use App\Services\PermissionResolver;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\Mapping\Entity;
|
||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
|
@ -36,7 +32,6 @@ use Symfony\Component\Validator\ConstraintValidator;
|
|||
|
||||
class NoLockoutValidator extends ConstraintValidator
|
||||
{
|
||||
|
||||
protected $resolver;
|
||||
protected $perm_structure;
|
||||
protected $security;
|
||||
|
@ -53,7 +48,7 @@ class NoLockoutValidator extends ConstraintValidator
|
|||
/**
|
||||
* Checks if the passed value is valid.
|
||||
*
|
||||
* @param mixed $value The value that should be validated
|
||||
* @param mixed $value The value that should be validated
|
||||
* @param Constraint $constraint The constraint for the validation
|
||||
*/
|
||||
public function validate($value, Constraint $constraint)
|
||||
|
@ -62,24 +57,22 @@ class NoLockoutValidator extends ConstraintValidator
|
|||
throw new UnexpectedTypeException($constraint, NoLockout::class);
|
||||
}
|
||||
|
||||
|
||||
$perm_holder = $value;
|
||||
|
||||
//Prevent that a user revokes its own change_permission perm (prevent the user to lock out itself)
|
||||
if ($perm_holder instanceof User || $perm_holder instanceof Group) {
|
||||
|
||||
$user = $this->security->getUser();
|
||||
|
||||
if ($user === null) {
|
||||
if (null === $user) {
|
||||
$user = $this->entityManager->getRepository(User::class)->getAnonymousUser();
|
||||
}
|
||||
|
||||
if ($user instanceof User) {
|
||||
//Check if we the change_permission permission has changed from allow to disallow
|
||||
if (($this->resolver->inherit($user, 'users', 'edit_permissions') ?? false) === false) {
|
||||
if (false === ($this->resolver->inherit($user, 'users', 'edit_permissions') ?? false)) {
|
||||
$this->context->addViolation($constraint->message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue