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;
|
const { libraries, queries } = tenantContext;
|
||||||
|
|
||||||
router.post(`${experienceRoutes.verification}/backup-code/generate`, async (ctx, next) => {
|
router.post(
|
||||||
const { experienceInteraction } = ctx;
|
`${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(
|
const backupCodeVerificationRecord = BackupCodeVerification.create(
|
||||||
libraries,
|
libraries,
|
||||||
queries,
|
queries,
|
||||||
experienceInteraction.identifiedUserId
|
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 = {
|
ctx.body = {
|
||||||
verificationId: backupCodeVerificationRecord.id,
|
verificationId: backupCodeVerificationRecord.id,
|
||||||
};
|
codes,
|
||||||
|
};
|
||||||
|
|
||||||
return next();
|
return next();
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
`${experienceRoutes.verification}/backup-code/generate`,
|
`${experienceRoutes.verification}/backup-code/generate`,
|
||||||
|
|
Loading…
Reference in a new issue