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

Revert "refactor(ui): optimize api call stack" (#3011)

This commit is contained in:
simeng-li 2023-01-28 12:01:49 +08:00 committed by GitHub
parent 5b95d0bae5
commit 53f49df621
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -114,29 +114,27 @@ export const verifyForgotPasswordVerificationCodeIdentifier = async (
};
export const signInWithVerifiedIdentifier = async () => {
await Promise.all([
api.delete(`${interactionPrefix}/profile`),
api.put(`${interactionPrefix}/event`, {
json: {
event: InteractionEvent.SignIn,
},
}),
]);
await api.delete(`${interactionPrefix}/profile`);
await api.put(`${interactionPrefix}/event`, {
json: {
event: InteractionEvent.SignIn,
},
});
return api.post(`${interactionPrefix}/submit`).json<Response>();
};
export const registerWithVerifiedIdentifier = async (payload: SendVerificationCodePayload) => {
await Promise.all([
api.put(`${interactionPrefix}/event`, {
json: {
event: InteractionEvent.Register,
},
}),
api.put(`${interactionPrefix}/profile`, {
json: payload,
}),
]);
await api.put(`${interactionPrefix}/event`, {
json: {
event: InteractionEvent.Register,
},
});
await api.put(`${interactionPrefix}/profile`, {
json: payload,
});
return api.post(`${interactionPrefix}/submit`).json<Response>();
};
@ -174,33 +172,31 @@ export const signInWithSocial = async (payload: SocialConnectorPayload) => {
};
export const registerWithVerifiedSocial = async (connectorId: string) => {
await Promise.all([
api.put(`${interactionPrefix}/event`, {
json: {
event: InteractionEvent.Register,
},
}),
api.patch(`${interactionPrefix}/profile`, {
json: {
connectorId,
},
}),
]);
await api.put(`${interactionPrefix}/event`, {
json: {
event: InteractionEvent.Register,
},
});
await api.patch(`${interactionPrefix}/profile`, {
json: {
connectorId,
},
});
return api.post(`${interactionPrefix}/submit`).json<Response>();
};
export const bindSocialRelatedUser = async (payload: SocialEmailPayload | SocialPhonePayload) => {
await Promise.all([
api.patch(`${interactionPrefix}/identifiers`, {
json: payload,
}),
api.patch(`${interactionPrefix}/profile`, {
json: {
connectorId: payload.connectorId,
},
}),
]);
await api.patch(`${interactionPrefix}/identifiers`, {
json: payload,
});
await api.patch(`${interactionPrefix}/profile`, {
json: {
connectorId: payload.connectorId,
},
});
return api.post(`${interactionPrefix}/submit`).json<Response>();
};
@ -208,18 +204,17 @@ export const bindSocialRelatedUser = async (payload: SocialEmailPayload | Social
export const linkWithSocial = async (connectorId: string) => {
// Sign-in with pre-verified email/phone identifier instead and replace the email/phone profile with connectorId.
await Promise.all([
api.put(`${interactionPrefix}/event`, {
json: {
event: InteractionEvent.SignIn,
},
}),
api.put(`${interactionPrefix}/profile`, {
json: {
connectorId,
},
}),
]);
await api.put(`${interactionPrefix}/event`, {
json: {
event: InteractionEvent.SignIn,
},
});
await api.put(`${interactionPrefix}/profile`, {
json: {
connectorId,
},
});
return api.post(`${interactionPrefix}/submit`).json<Response>();
};