Skip to content

Commit

Permalink
Additional commit for CFM-333
Browse files Browse the repository at this point in the history
  • Loading branch information
Benn Oshrin committed Nov 28, 2024
1 parent 045abe1 commit 4787fbd
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
6 changes: 3 additions & 3 deletions app/resources/locales/en_US/enumeration.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -462,9 +465,6 @@ msgstr "Status Updated"
msgid "PetitionStatusEnum.A"
msgstr "Active"

msgid "PetitionStatusEnum.EV"
msgstr "Email Verified"

msgid "PetitionStatusEnum.Y"
msgstr "Approved"

Expand Down
4 changes: 3 additions & 1 deletion app/src/Model/Table/VerificationsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -269,6 +269,8 @@ public function verifyCode(int $id, string $code) {
$verification->verification_time = time();

$this->saveOrFail($verification);

return true;
}

/**
Expand Down

0 comments on commit 4787fbd

Please sign in to comment.