0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-30 20:33:54 -05:00

fix(core): fix api payload

fix api payload
This commit is contained in:
simeng-li 2024-07-26 12:13:59 +08:00
parent 68193c3376
commit 65efced999
No known key found for this signature in database
GPG key ID: 14EA7BB1541E8075

View file

@ -18,29 +18,40 @@ export default function backupCodeVerificationRoutes<T extends ExperienceInterac
) {
const { libraries, queries } = tenantContext;
router.post(`${experienceRoutes.verification}/backup-code/generate`, async (ctx, next) => {
const { experienceInteraction } = ctx;
router.post(
`${experienceRoutes.verification}/backup-code/generate`,
koaGuard({
status: [200, 400],
response: z.object({
verificationId: z.string(),
codes: z.array(z.string()),
}),
}),
async (ctx, next) => {
const { experienceInteraction } = ctx;
assertThat(experienceInteraction.identifiedUserId, 'session.identifier_not_found');
assertThat(experienceInteraction.identifiedUserId, 'session.identifier_not_found');
const backupCodeVerificationRecord = BackupCodeVerification.create(
libraries,
queries,
experienceInteraction.identifiedUserId
);
const backupCodeVerificationRecord = BackupCodeVerification.create(
libraries,
queries,
experienceInteraction.identifiedUserId
);
backupCodeVerificationRecord.generate();
const codes = backupCodeVerificationRecord.generate();
ctx.experienceInteraction.setVerificationRecord(backupCodeVerificationRecord);
ctx.experienceInteraction.setVerificationRecord(backupCodeVerificationRecord);
await ctx.experienceInteraction.save();
await ctx.experienceInteraction.save();
ctx.body = {
verificationId: backupCodeVerificationRecord.id,
};
ctx.body = {
verificationId: backupCodeVerificationRecord.id,
codes,
};
return next();
});
return next();
}
);
router.post(
`${experienceRoutes.verification}/backup-code/generate`,