Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): implement verification code verification API #6001

Merged
merged 2 commits into from
Jul 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
chore(core): fix rebase issue
fix rebase issue
  • Loading branch information
simeng-li committed Jul 5, 2024
commit 2e27e898f70702e38c184e2e26c9f2698d370ff2
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,25 @@
status: [200, 400, 404, 501],
}),
async (ctx, next) => {
const { identifier, interactionEvent } = ctx.guard.body;

const codeVerification = await CodeVerification.create(
libraries,
queries,
identifier,
interactionEvent
);

ctx.experienceInteraction.appendVerificationRecord(codeVerification);
ctx.experienceInteraction.setVerificationRecord(codeVerification);

await ctx.experienceInteraction.save();

ctx.body = {
verificationId: codeVerification.id,
};

await next();
}

Check warning on line 55 in packages/core/src/routes/experience/verification-routes/verification-code.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/routes/experience/verification-routes/verification-code.ts#L37-L55

Added lines #L37 - L55 were not covered by tests
);

router.post(
Expand All @@ -70,27 +70,27 @@
status: [200, 400, 404, 501],
}),
async (ctx, next) => {
const { verificationId, code, identifier } = ctx.guard.body;

const codeVerificationRecord =
ctx.experienceInteraction.getVerificationRecordById(verificationId);

assertThat(
codeVerificationRecord &&
// Make the Verification type checker happy
codeVerificationRecord.type === VerificationType.VerificationCode,
new RequestError({ code: 'session.verification_session_not_found', status: 404 })
);

await codeVerificationRecord.verify(identifier, code);

await ctx.experienceInteraction.save();

ctx.body = {
verificationId: codeVerificationRecord.id,
};

return next();
}

Check warning on line 94 in packages/core/src/routes/experience/verification-routes/verification-code.ts

View check run for this annotation

Codecov / codecov/patch

packages/core/src/routes/experience/verification-routes/verification-code.ts#L73-L94

Added lines #L73 - L94 were not covered by tests
);
}
Loading