0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

fix(core,schemas): fix continue flow with log and interaction merge

This commit is contained in:
wangsijie 2022-11-30 11:21:06 +08:00
parent 3b0aa43975
commit 549cb66a92
No known key found for this signature in database
GPG key ID: 1EA50084233D66BE
3 changed files with 20 additions and 0 deletions

View file

@ -122,6 +122,7 @@ export default function passwordlessRoutes<T extends AnonymousRouter>(
}
await assignVerificationResult(ctx, provider, { flow, phone });
ctx.status = 204;
return next();
}
@ -171,6 +172,7 @@ export default function passwordlessRoutes<T extends AnonymousRouter>(
}
await assignVerificationResult(ctx, provider, { flow, email });
ctx.status = 204;
return next();
}

View file

@ -92,7 +92,9 @@ export const assignVerificationResult = async (
expiresAt: addSeconds(Date.now(), verificationTimeout).toISOString(),
};
const details = await provider.interactionDetails(ctx.req, ctx.res);
await provider.interactionResult(ctx.req, ctx.res, {
...details.result,
verification,
});
};
@ -114,7 +116,9 @@ export const assignContinueSignInResult = async (
provider: Provider,
payload: { userId: string }
) => {
const details = await provider.interactionDetails(ctx.req, ctx.res);
await provider.interactionResult(ctx.req, ctx.res, {
...details.result,
continueSignIn: {
...payload,
expiresAt: addSeconds(Date.now(), continueSignInTimeout).toISOString(),

View file

@ -188,6 +188,18 @@ const continueSmsSendPasscodeLogPayloadGuard = arbitraryLogPayloadGuard.and(
})
);
const continueEmailLogPayloadGuard = arbitraryLogPayloadGuard.and(
z.object({
email: z.string().optional(),
})
);
const continueSmsLogPayloadGuard = arbitraryLogPayloadGuard.and(
z.object({
phone: z.string().optional(),
})
);
export enum TokenType {
AccessToken = 'AccessToken',
RefreshToken = 'RefreshToken',
@ -238,6 +250,8 @@ const logPayloadsGuard = z.object({
ForgotPasswordReset: forgotPasswordResetLogPayloadGuard,
ContinueEmailSendPasscode: continueEmailSendPasscodeLogPayloadGuard,
ContinueSmsSendPasscode: continueSmsSendPasscodeLogPayloadGuard,
ContinueEmail: continueEmailLogPayloadGuard,
ContinueSms: continueSmsLogPayloadGuard,
CodeExchangeToken: exchangeTokenLogPayloadGuard,
RefreshTokenExchangeToken: exchangeTokenLogPayloadGuard,
RevokeToken: revokeTokenLogPayloadGuard,