Commit 57c79fc6 by Yvon Kerdoncuff

Merge branch '5870-fix-issue-of-auto-connect-as-adherent-after-presta-enabled' into 'ssa-gironde'

show modal role choice first time user logs in with a prestataire enabled

See merge request cooperatic/kohinos-tav!62
parents 6e0157a8 704119f7
......@@ -207,6 +207,14 @@ class User extends BaseUser
*/
private $comment;
/**
* This flag is set to false as soon as a user with an enabled prestataire logs in.
*
* @var bool
* @ORM\Column(type="boolean", nullable=false, options={"default" : true})
*/
private bool $beforeFirstLoginWithPrestaEnabled;
public function __construct()
{
parent::__construct();
......@@ -826,4 +834,13 @@ class User extends BaseUser
return $this;
}
public function getBeforeFirstLoginWithPrestaEnabled(): bool
{
return $this->beforeFirstLoginWithPrestaEnabled;
}
public function setBeforeFirstLoginWithPrestaEnabled($var)
{
$this->beforeFirstLoginWithPrestaEnabled = $var;
}
}
<?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 Version20240302095543 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 before_first_login_with_presta_enabled TINYINT(1) DEFAULT \'1\' NOT 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 utf8 DEFAULT NULL COLLATE `utf8_general_ci` COMMENT \'(DC2Type:personal_data)\'');
$this->addSql('ALTER TABLE user DROP before_first_login_with_presta_enabled');
}
}
......@@ -206,6 +206,23 @@ class AppExtension extends AbstractExtension
public function showModalGroupChoice()
{
if (null != $this->security->getUser()) {
/* Enable display of modal after the first login of a user,
* the first time there is an enable prestataire associated to the account.
*
* The user now realizes that a new role is available and can be picked up.
*
* Otherwise, in case prestataire is enabled after first login, user would login automaticaly as
* adherent again without being noticed that prestataire has been enabled.
*/
if($this->container->getParameter('presta_self_init_and_eval')) {
$hasPrestataireEnabled = $this->security->getUser()->getPrestataires() && !$this->security->getUser()->getPrestataires()->isEmpty();
$nowIsfirstLoginWithPrestaEnabled = $this->security->getUser()->getBeforeFirstLoginWithPrestaEnabled();
if ($hasPrestataireEnabled && $nowIsfirstLoginWithPrestaEnabled) {
$this->security->getUser()->setBeforeFirstLoginWithPrestaEnabled(false);
$this->em->flush();
return true;
}
}
if (count($this->security->getUser()->getPossiblegroups()) > 1 && 0 == count($this->security->getUser()->getGroups())) {
return true;
}
......
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