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:
parent
68193c3376
commit
65efced999
1 changed files with 27 additions and 16 deletions
|
@ -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`,
|
||||
|
|
Loading…
Reference in a new issue