Skip to content

Commit

Permalink
fix(core): fix google one tap verification error
Browse files Browse the repository at this point in the history
fix google one tap verification error
  • Loading branch information
simeng-li committed Aug 7, 2024
1 parent e2d7c8e commit 70ced56
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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(
Expand All @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 70ced56

Please sign in to comment.