Skip to content

Commit

Permalink
Rebase main
Browse files Browse the repository at this point in the history
  • Loading branch information
Fan2Shrek committed Mar 19, 2024
1 parent 3255ea8 commit 76f3666
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/Controller/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ public function editAction(Request $request, UserNotifier $userNotifier): Respon
throw $this->createAccessDeniedException('This user does not have access to this section.');
}

$oldEmail = $user->getEmail();
$form = $this->createForm(ProfileFormType::class, $user);

$form->handleRequest($request);
Expand All @@ -132,13 +131,15 @@ public function editAction(Request $request, UserNotifier $userNotifier): Respon

$diffs = array_intersect(array_keys($changeSet), ['email', 'username']);

if (!empty($diffs) && $user instanceof User) {
if (!empty($diffs)) {
$reason = sprintf('Your %s has been changed', implode(' and ', $diffs));
$userNotifier->notifyChange($changeSet['email'][0] ?? $user->getEmail(), $reason);
}

if ($oldEmail !== $user->getEmail()) {
$user->resetPasswordRequest();
if (isset($changeSet['email'][0])) {
$userNotifier->notifyChange($changeSet['email'][0], $reason);
$user->resetPasswordRequest();
}

$userNotifier->notifyChange($user->getEmail(), $reason);
}

$this->getEM()->persist($user);
Expand Down

0 comments on commit 76f3666

Please sign in to comment.