Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Sécurité - Login] Ne pas activer par défaut les user avec ROLE_USAGER #2535

Merged
merged 1 commit into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/Manager/UserManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ public function createUsagerFromSignalement(Signalement $signalement, string $ty
);

$user->setIsMailingActive(true);
$user->setStatut(User::STATUS_ACTIVE);
$this->save($user);
}

Expand Down
1 change: 1 addition & 0 deletions src/Repository/UserRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public function findInactiveWithNbAffectationPending(): array
FROM user u
LEFT JOIN affectation a on a.partner_id = u.partner_id and a.statut = 0
WHERE u.statut = 0 AND DATE(u.created_at) <= (DATE(NOW()) - INTERVAL 10 DAY)
AND u.roles NOT LIKE "%ROLE_USAGER%"
GROUP BY u.email, u.created_at
ORDER BY nb_signalements desc';

Expand Down
2 changes: 1 addition & 1 deletion src/Security/BackOfficeAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function authenticate(Request $request): Passport

return new Passport(
new UserBadge($email, function (string $email) {
return $this->userRepository->findOneBy(['email' => $email, 'statut' => [User::STATUS_ACTIVE, User::STATUS_INACTIVE]]);
return $this->userRepository->findOneBy(['email' => $email, 'statut' => User::STATUS_ACTIVE]);
}),
new PasswordCredentials($request->request->get('password', '')),
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function testDisplayMessageSuccessfully(): void
$commandTester->assertCommandIsSuccessful();

$output = $commandTester->getDisplay();
$this->assertStringContainsString('9 users has been notified', $output);
$this->assertEmailCount(10);
$this->assertStringContainsString('8 users has been notified', $output);
$this->assertEmailCount(9);
}
}
2 changes: 1 addition & 1 deletion tests/Functional/Repository/UserRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function testFindInactiveUserWithNbAffectations(): void
$users = $userRepository->findInactiveWithNbAffectationPending();

$this->assertIsArray($users);
$this->assertCount(9, $users);
$this->assertCount(8, $users);
foreach ($users as $user) {
$this->assertArrayHasKey('email', $user);
if (!empty($user['signalements'])) {
Expand Down
Loading