Skip to content

Commit 3a7071a

Browse files
committed
Ensure spammers cannot be re-enabled by accident
1 parent 9a032a5 commit 3a7071a

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

src/Controller/ResetPasswordController.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ public function reset(Request $request, UserPasswordHasherInterface $passwordHas
9797

9898
if ($form->isSubmitted() && $form->isValid()) {
9999
$user->resetPasswordRequest();
100-
if (!$user->hasRole('ROLE_SPAMMER')) {
101-
$user->setEnabled(true);
102-
}
100+
$user->setEnabled(true);
103101

104102
// Encode the plain password, and set it.
105103
$encodedPassword = $passwordHasher->hashPassword(

src/Entity/User.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,10 @@ public function setEmailCanonical(string $emailCanonical): void
465465

466466
public function setEnabled(bool $boolean): void
467467
{
468+
if ($this->hasRole('ROLE_SPAMMER')) {
469+
$boolean = false;
470+
}
471+
468472
$this->enabled = $boolean;
469473
}
470474

src/Security/EmailVerifier.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,7 @@ public function handleEmailConfirmation(Request $request, UserInterface $user):
6666
}
6767

6868
$this->verifyEmailHelper->validateEmailConfirmationFromRequest($request, (string) $user->getId(), $user->getEmail());
69-
70-
if (!$user->hasRole('ROLE_SPAMMER')) {
71-
$user->setEnabled(true);
72-
}
69+
$user->setEnabled(true);
7370

7471
$this->getEM()->persist($user);
7572
$this->getEM()->flush();

0 commit comments

Comments
 (0)