Merge branch 'dev/portailV2' into 'develop'
update user checker See merge request easy-solutions/apps/easyportal!3
This commit is contained in:
commit
0ad22cc465
|
|
@ -1,6 +0,0 @@
|
|||
# define your env variables for the test env here
|
||||
KERNEL_CLASS='App\Kernel'
|
||||
APP_SECRET='$ecretf0rt3st'
|
||||
SYMFONY_DEPRECATIONS_HELPER=999999
|
||||
PANTHER_APP_ENV=panther
|
||||
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -9,9 +9,17 @@
|
|||
<ini name="display_errors" value="1" />
|
||||
<ini name="error_reporting" value="-1" />
|
||||
<server name="APP_ENV" value="test" force="true" />
|
||||
<server name="APPLICATION" value="solutions" force="true" />
|
||||
<server name="AWS_S3_PORTAL_URL" value="solutions" force="true" />
|
||||
<env name="S3_PORTAL_BUCKET" value="test-bucket-placeholder" force="true" />
|
||||
<server name="AWS_ENDPOINT" value="solutions" force="true" />
|
||||
<server name="SHELL_VERBOSITY" value="-1" />
|
||||
</php>
|
||||
|
||||
<extensions>
|
||||
<bootstrap class="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension" />
|
||||
</extensions>
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="Project Test Suite">
|
||||
<directory>tests</directory>
|
||||
|
|
|
|||
|
|
@ -21,20 +21,25 @@ class UserChecker implements UserCheckerInterface
|
|||
|
||||
public function checkPostAuth(UserInterface $user): void
|
||||
{
|
||||
// runs after credentials are validated
|
||||
if (method_exists($user, 'isDeleted') && $user->isDeleted()) {
|
||||
throw new CustomUserMessageAccountStatusException('Votre compte a été supprimé.');
|
||||
//if not Super admin, perform checks
|
||||
// runs after credentials are validated
|
||||
if (method_exists($user, 'isDeleted') && $user->isDeleted()) {
|
||||
throw new CustomUserMessageAccountStatusException('Votre compte a été supprimé.');
|
||||
}
|
||||
|
||||
// check if the user account is active
|
||||
if (method_exists($user, 'isActive') && !$user->isActive()) {
|
||||
throw new CustomUserMessageAccountStatusException('Votre compte est désactivé.');
|
||||
}
|
||||
if (!in_array('ROLE_SUPER_ADMIN', $user->getRoles(), true))
|
||||
{
|
||||
|
||||
//check if the user is in an organization
|
||||
$uo = $this->entityManager->getRepository(UsersOrganizations::class)->findOneBy(['users' => $user, 'isActive' => true]);
|
||||
if (!$uo) {
|
||||
throw new CustomUserMessageAccountStatusException('Vous n\'êtes pas relié à une organisation. veuillez contacter un administrateur.');
|
||||
}
|
||||
}
|
||||
|
||||
// check if the user account is active
|
||||
if (method_exists($user, 'isActive') && !$user->isActive()) {
|
||||
throw new CustomUserMessageAccountStatusException('Votre compte est désactivé.');
|
||||
}
|
||||
|
||||
//check if the user is in an organization
|
||||
$uo = $this->entityManager->getRepository(UsersOrganizations::class)->findOneBy(['users' => $user, 'isActive' => true]);
|
||||
if (!$uo) {
|
||||
throw new CustomUserMessageAccountStatusException('Vous n\'êtes pas relié à une organisation. veuillez contacter un administrateur.');
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue