Project 'cooperatic/kohinos-tav' was moved to 'agplv3/kohinos-tav'. Please update any links and bookmarks that may still have the old path.
Commit d1437332 by Félicie

Merge branch '4123-explanation-for-deactivating-user' into 'develop'

add comment field to User for admin

See merge request cooperatic/kohinos-tav!9
parents 735b3a14 1c7713d8
......@@ -74,6 +74,7 @@ security:
switch_user:
provider: fos_userbundle
access_denied_handler: App\Security\AccessDeniedHandler
user_checker: App\Security\UserChecker
encoders:
FOS\UserBundle\Model\UserInterface:
......
......@@ -267,6 +267,16 @@ class UserController extends AbstractController
$adherent = $data["adherent"];
$adherent_code = $adherent->getPaymentCode();
// if adherent account isn't enabled
if (!$adherent->getUser()->isEnabled()) {
$this->addFlash(
'error',
$this->translator->trans('Le compte de l\'habitant·e est désactivé.')
);
goto end;
}
// if adherent doesn't have a validation code
if (is_null($adherent_code)) {
$this->addFlash(
......
......@@ -202,6 +202,11 @@ class User extends BaseUser
*/
public $canValidateAchat;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $comment;
public function __construct()
{
parent::__construct();
......@@ -809,4 +814,16 @@ class User extends BaseUser
return $this;
}
public function getComment(): ?string
{
return $this->comment;
}
public function setComment(?string $comment): self
{
$this->comment = $comment;
return $this;
}
}
......@@ -46,6 +46,13 @@ class UserFormType extends AbstractType
->add('enabled', null, [
'label' => 'Activé ?',
])
->add('comment', null, [
'label' => 'Commentaire',
'required' => false,
'attr' => array(
'placeholder' => 'Indiquez par exemple pourquoi ce compte a été désactivé'
)
])
;
}
......
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20221129140532 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE prestataire CHANGE iban iban LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:personal_data)\'');
$this->addSql('ALTER TABLE user ADD comment LONGTEXT DEFAULT NULL');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE prestataire CHANGE iban iban LONGTEXT CHARACTER SET utf8mb3 DEFAULT NULL COLLATE `utf8mb3_general_ci` COMMENT \'(DC2Type:personal_data)\'');
$this->addSql('ALTER TABLE user DROP comment');
}
}
<?php
namespace App\Security;
use App\Entity\User as AppUser;
use Symfony\Component\Security\Core\Exception\AccountExpiredException;
use Symfony\Component\Security\Core\Exception\CustomUserMessageAuthenticationException;
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 AppUser) {
return;
}
if (!$user->isEnabled()) {
throw new CustomUserMessageAuthenticationException('Account is disabled.');
}
}
public function checkPostAuth(UserInterface $user): void
{
if (!$user instanceof AppUser) {
return;
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment