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

fix(core): fix google one tap verification error

fix google one tap verification error
This commit is contained in:
simeng-li 2024-08-05 10:58:25 +08:00
parent 4b6039c585
commit 6eff894a8f
No known key found for this signature in database
GPG key ID: 14EA7BB1541E8075
2 changed files with 18 additions and 11 deletions

View file

@ -90,9 +90,12 @@ export default function socialVerificationRoutes<T extends ExperienceInteraction
action: Action.Submit,
}),
async (ctx, next) => {
const { connectorId } = ctx.params;
const { connectorId } = ctx.guard.params;
const { connectorData, verificationId } = ctx.guard.body;
const { verificationAuditLog } = ctx;
const {
socials: { getConnector },
} = libraries;
verificationAuditLog.append({
payload: {
@ -102,17 +105,12 @@ export default function socialVerificationRoutes<T extends ExperienceInteraction
},
});
const socialVerificationRecord = (() => {
if (verificationId) {
return ctx.experienceInteraction.getVerificationRecordByTypeAndId(
VerificationType.Social,
verificationId
);
}
const connector = await getConnector(connectorId);
const socialVerificationRecord = (() => {
// Check if is Google one tap verification
if (
connectorId === GoogleConnector.factoryId &&
connector.metadata.id === GoogleConnector.factoryId &&
connectorData[GoogleConnector.oneTapParams.credential]
) {
const socialVerificationRecord = SocialVerification.create(
@ -124,6 +122,13 @@ export default function socialVerificationRoutes<T extends ExperienceInteraction
return socialVerificationRecord;
}
if (verificationId) {
return ctx.experienceInteraction.getVerificationRecordByTypeAndId(
VerificationType.Social,
verificationId
);
}
// No verificationId provided and not Google one tap callback
throw new RequestError({
code: 'session.verification_session_not_found',

View file

@ -57,16 +57,18 @@ export const verifySocialIdentity = async (
{ provider, libraries }: TenantContext
): Promise<SocialUserInfo> => {
const {
socials: { getUserInfo },
socials: { getUserInfo, getConnector },
} = libraries;
const log = ctx.createLog('Interaction.SignIn.Identifier.Social.Submit');
log.append({ connectorId, connectorData });
const connector = await getConnector(connectorId);
// Verify the CSRF token if it's a Google connector and has credential (a Google One Tap
// verification)
if (
connectorId === GoogleConnector.factoryId &&
connector.metadata.id === GoogleConnector.factoryId &&
connectorData[GoogleConnector.oneTapParams.credential]
) {
const csrfToken = connectorData[GoogleConnector.oneTapParams.csrfToken];