diff --git a/app/plugins/CoreEnroller/src/Controller/EmailVerifiersController.php b/app/plugins/CoreEnroller/src/Controller/EmailVerifiersController.php index 179713650..16e320f06 100644 --- a/app/plugins/CoreEnroller/src/Controller/EmailVerifiersController.php +++ b/app/plugins/CoreEnroller/src/Controller/EmailVerifiersController.php @@ -118,7 +118,12 @@ public function dispatch(string $id) { $code = $this->requestParam('code'); try { - $PetitionVerifications->verifyCode($petition->id, $mail, $code); + $PetitionVerifications->verifyCode( + $petition->id, + $cfg->enrollment_flow_step_id, + $mail, + $code + ); $this->llog('debug', "Successfully verified $mail"); diff --git a/app/plugins/CoreEnroller/src/Model/Table/PetitionVerificationsTable.php b/app/plugins/CoreEnroller/src/Model/Table/PetitionVerificationsTable.php index 6b7438bb6..510dc7889 100644 --- a/app/plugins/CoreEnroller/src/Model/Table/PetitionVerificationsTable.php +++ b/app/plugins/CoreEnroller/src/Model/Table/PetitionVerificationsTable.php @@ -105,12 +105,13 @@ public function initialize(array $config): void { * * @since COmanage Registry v5.1.0 * @param integer $petitionId Petition ID + * @param integer $enrollmentFlowStepId Enrollment Flow Step ID * @param string $mail Email Address that was verified * @return bool true if validation is successful * @throws \InvalidArgumentException */ - public function verifyCode(int $petitionId, string $mail, string $code) { + public function verifyCode(int $petitionId, int $enrollmentFlowStepId, string $mail, string $code): bool { // Find the PetitionVerification for the requested petition and address, // then use the verification ID to process the code. @@ -121,7 +122,21 @@ public function verifyCode(int $petitionId, string $mail, string $code) { ]) ->firstOrFail(); - return $this->Verifications->verifyCode($pVerification->verification_id, $code); + // This will throw an error on failure + $this->Verifications->verifyCode($pVerification->verification_id, $code); + + // Record Petition History + + $this->Petitions->PetitionHistoryRecords->record( + petitionId: $petitionId, + enrollmentFlowStepId: $enrollmentFlowStepId, + action: PetitionActionEnum::EmailVerified, + comment: __d('core_enroller', 'result.EmailVerifiers.verified.history', [$mail, __d('enumeration', 'VerificationMethodEnum.C')]) +// We don't have $actorPersonId yet... +// ?int $actorPersonId=null + ); + + return true; } /** diff --git a/app/plugins/CoreEnroller/templates/EmailVerifiers/dispatch.inc b/app/plugins/CoreEnroller/templates/EmailVerifiers/dispatch.inc index 84fe135d5..62b3b9c4e 100644 --- a/app/plugins/CoreEnroller/templates/EmailVerifiers/dispatch.inc +++ b/app/plugins/CoreEnroller/templates/EmailVerifiers/dispatch.inc @@ -125,8 +125,8 @@ if($vv_action == 'dispatch') { } elseif($vv_op == 'verify') { if(!empty($vv_verify_address)) { // Render a form prompting for the code that was sent to the Enrollee - - print __d('core_enroller', 'information.EmailVerifiers.code_sent', [$vv_verified_address]); + + print __d('core_enroller', 'information.EmailVerifiers.code_sent', [$vv_verify_address]); $this->Field->enableFormEditMode(); diff --git a/app/resources/locales/en_US/enumeration.po b/app/resources/locales/en_US/enumeration.po index e730e6c30..610d3394d 100644 --- a/app/resources/locales/en_US/enumeration.po +++ b/app/resources/locales/en_US/enumeration.po @@ -450,6 +450,9 @@ msgstr "Country Code, Area Code, Number, Extension" msgid "PetitionActionEnum.AU" msgstr "Attributes Updated" +msgid "PetitionActionEnum.EV" +msgstr "Email Verified" + msgid "PetitionActionEnum.F" msgstr "Finalized" @@ -462,9 +465,6 @@ msgstr "Status Updated" msgid "PetitionStatusEnum.A" msgstr "Active" -msgid "PetitionStatusEnum.EV" -msgstr "Email Verified" - msgid "PetitionStatusEnum.Y" msgstr "Approved" diff --git a/app/src/Model/Table/VerificationsTable.php b/app/src/Model/Table/VerificationsTable.php index 78e744c10..f75ab25cc 100644 --- a/app/src/Model/Table/VerificationsTable.php +++ b/app/src/Model/Table/VerificationsTable.php @@ -245,7 +245,7 @@ public function unverify(int $emailAddressId) { * @throws \InvalidArgumentException */ - public function verifyCode(int $id, string $code) { + public function verifyCode(int $id, string $code): bool { $verification = $this->get($id); if($verification->verification_time) { @@ -269,6 +269,8 @@ public function verifyCode(int $id, string $code) { $verification->verification_time = time(); $this->saveOrFail($verification); + + return true; } /**