Skip to content

Commit

Permalink
Fix GH-291, member must be able to keep own email
Browse files Browse the repository at this point in the history
  • Loading branch information
rinkp committed May 30, 2023
1 parent 593bc1c commit 581eaad
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions module/Database/src/Controller/MemberController.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,19 @@ public function renewAction(): ViewModel
$request = $this->getRequest();

if ($request->isPost()) {
$oldEmail = $form->get('email')->getValue();
$form->setMutableData($request->getPost()->toArray());

// find if there is an earlier member with the same email
// if we changed our email
// check if it is not in use by someone else
if (
$this->memberService->getMemberMapper()->hasMemberWith($form->get('email')->getValue())
|| $this->memberService->getProspectiveMemberMapper()->hasMemberWith($form->get('email')->getValue())
$oldEmail !== $form->get('email')->getValue()
&& (
$this->memberService->getMemberMapper()->hasMemberWith($form->get('email')->getValue())
|| $this->memberService->getProspectiveMemberMapper()->hasMemberWith(
$form->get('email')->getValue(),
)
)
) {
$form->get('email')->setMessages(['There already is a member with this email address.']);
} elseif ($form->isValid()) {
Expand Down

0 comments on commit 581eaad

Please sign in to comment.