fix(activeuser): reset structure bdd
Some checks reported warnings
Cadoles/nineskeletor/pipeline/head This commit is unstable
Some checks reported warnings
Cadoles/nineskeletor/pipeline/head This commit is unstable
This commit is contained in:
@ -98,6 +98,7 @@ class InitCommand extends Command
|
||||
$user->setApikey(Uuid::uuid4());
|
||||
$user->setAvatar('admin.jpg');
|
||||
$user->setIsVisible(true);
|
||||
$user->setIsActive(true);
|
||||
$user->setNiveau01($niveau01);
|
||||
|
||||
$this->em->persist($user);
|
||||
|
@ -321,6 +321,7 @@ class SynchroCommand extends Command
|
||||
if (!$user) {
|
||||
$user = new User();
|
||||
$user->setUsername($ldapentry[$this->username]);
|
||||
$user->setIsactive(true);
|
||||
$user->setIsvisible(true);
|
||||
$user->setApikey(Uuid::uuid4());
|
||||
$user->setRole('ROLE_USER');
|
||||
@ -860,6 +861,7 @@ class SynchroCommand extends Command
|
||||
if (!$user) {
|
||||
$user = new User();
|
||||
$user->setUsername($nineuser->userlogin);
|
||||
$user->setIsactive(true);
|
||||
$user->setIsvisible(true);
|
||||
$user->setApikey(Uuid::uuid4());
|
||||
$user->setRole('ROLE_USER');
|
||||
|
@ -194,7 +194,7 @@ class RegistrationController extends AbstractController
|
||||
|
||||
$data = new Registration();
|
||||
$data->setIsvisible(true);
|
||||
|
||||
|
||||
// Création du formulaire
|
||||
$form = $this->createForm(Form::class, $data, [
|
||||
'mode' => 'submit',
|
||||
@ -505,6 +505,7 @@ class RegistrationController extends AbstractController
|
||||
$user->setFirstname($data->getFirstname());
|
||||
$user->setSalt($data->getSalt());
|
||||
$user->setPasswordDirect($data->getPassword());
|
||||
$user->setIsactive(true);
|
||||
$user->setIsvisible($data->isIsvisible());
|
||||
$user->setMotivation($data->getMotivation());
|
||||
$user->setNote($data->getNote());
|
||||
|
@ -135,6 +135,7 @@ class SecurityController extends AbstractController
|
||||
$user = $this->submituser($username, $firstname, $lastname, $email, $avatar, $niveau01, $em);
|
||||
$user = $em->getRepository('App\Entity\Group')->calculateSSOGroup($user, $attributes);
|
||||
} elseif ($this->getParameter('casAutoupdate')) {
|
||||
if(!$user->Isactive()) return $this->redirect($this->generateUrl('app_noperm'));
|
||||
$this->submitSSONiveau01($attributes, $em);
|
||||
$this->submitSSOGroup($attributes, $em);
|
||||
$this->updateuser($user, $firstname, $lastname, $email, $avatar, $em);
|
||||
@ -513,6 +514,7 @@ class SecurityController extends AbstractController
|
||||
$user->setNiveau01($niveau01);
|
||||
|
||||
$user->setAvatar($avatar);
|
||||
$user->setIsactive(true);
|
||||
$user->setIsvisible(true);
|
||||
$user->setRole('ROLE_USER');
|
||||
|
||||
@ -554,6 +556,8 @@ class SecurityController extends AbstractController
|
||||
|
||||
private function autoconnexion($user, $redirect, Request $request)
|
||||
{
|
||||
if(!$user->isIsactive()) return $this->redirect($this->generateUrl('app_noperm'));
|
||||
|
||||
// Récupérer le token de l'utilisateur
|
||||
$token = new UsernamePasswordToken($user, 'main', $user->getRoles());
|
||||
$this->tokenstorage->setToken($token);
|
||||
|
@ -71,6 +71,11 @@ class User implements UserInterface, LegacyPasswordAuthenticatedUserInterface
|
||||
*/
|
||||
private $salt;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
protected $isactive;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=128, unique=true)
|
||||
*/
|
||||
@ -655,4 +660,16 @@ class User implements UserInterface, LegacyPasswordAuthenticatedUserInterface
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isIsactive(): ?bool
|
||||
{
|
||||
return $this->isactive;
|
||||
}
|
||||
|
||||
public function setIsactive(bool $isactive): self
|
||||
{
|
||||
$this->isactive = $isactive;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
34
src/Service/UserChecker.php
Normal file
34
src/Service/UserChecker.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Entity\User;
|
||||
use Symfony\Component\Security\Core\Exception\AccountExpiredException;
|
||||
use Symfony\Component\Security\Core\Exception\CustomUserMessageAccountStatusException;
|
||||
use Symfony\Component\Security\Core\User\UserCheckerInterface;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
|
||||
class UserChecker implements UserCheckerInterface
|
||||
{
|
||||
public function checkPreAuth(UserInterface $user): void
|
||||
{
|
||||
if (!$user instanceof User) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$user->isIsactive()) {
|
||||
throw new CustomUserMessageAccountStatusException('Your user account no longer exists.');
|
||||
}
|
||||
}
|
||||
|
||||
public function checkPostAuth(UserInterface $user): void
|
||||
{
|
||||
if (!$user instanceof User) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$user->isIsactive()) {
|
||||
throw new AccountExpiredException('...');
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user