From f1f2782c87ab9aeaf9d3237e9f20122e41ecdcbe Mon Sep 17 00:00:00 2001 From: Franz Bruckner Date: Tue, 6 Jan 2015 09:51:25 +0100 Subject: [PATCH] It's now possible to resend the verification E-Mail It's now possible to resend the verification E-Mail. E.g.: if the user did not receive the e-mail or lost it. As soon as the module resends the e-mail the request-time gets updated --- src/Service/UserRegistrationService.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Service/UserRegistrationService.php b/src/Service/UserRegistrationService.php index e8e2afa..63fc28b 100644 --- a/src/Service/UserRegistrationService.php +++ b/src/Service/UserRegistrationService.php @@ -85,7 +85,21 @@ public function onUserRegistration(EventInterface $e) */ public function sendVerificationEmail(UserInterface $user) { - $registrationRecord = $this->createRegistrationRecord($user); + // check if record exists + $registrationRecord = $this->getUserRegistrationMapper()->findByUser($user); + $this->getEventManager()->trigger(__FUNCTION__, $this, array('user' => $user, 'record' => $registrationRecord)); + + if (!$registrationRecord) { + // no record found, seems to be the first time + // create a new record + $registrationRecord = $this->createRegistrationRecord($user); + } else { + // a record was found + // update expiry + $registrationRecord->setRequestTime(new \DateTime()); + $this->getUserRegistrationMapper()->update($registrationRecord); + } + $this->mailer->sendVerificationEmail($registrationRecord); }