0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-06 20:40:08 -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 () => { export const signInWithVerifiedIdentifier = async () => {
await Promise.all([ await api.delete(`${interactionPrefix}/profile`);
api.delete(`${interactionPrefix}/profile`),
api.put(`${interactionPrefix}/event`, { await api.put(`${interactionPrefix}/event`, {
json: { json: {
event: InteractionEvent.SignIn, event: InteractionEvent.SignIn,
}, },
}), });
]);
return api.post(`${interactionPrefix}/submit`).json<Response>(); return api.post(`${interactionPrefix}/submit`).json<Response>();
}; };
export const registerWithVerifiedIdentifier = async (payload: SendVerificationCodePayload) => { export const registerWithVerifiedIdentifier = async (payload: SendVerificationCodePayload) => {
await Promise.all([ await api.put(`${interactionPrefix}/event`, {
api.put(`${interactionPrefix}/event`, { json: {
json: { event: InteractionEvent.Register,
event: InteractionEvent.Register, },
}, });
}),
api.put(`${interactionPrefix}/profile`, { await api.put(`${interactionPrefix}/profile`, {
json: payload, json: payload,
}), });
]);
return api.post(`${interactionPrefix}/submit`).json<Response>(); return api.post(`${interactionPrefix}/submit`).json<Response>();
}; };
@ -174,33 +172,31 @@ export const signInWithSocial = async (payload: SocialConnectorPayload) => {
}; };
export const registerWithVerifiedSocial = async (connectorId: string) => { export const registerWithVerifiedSocial = async (connectorId: string) => {
await Promise.all([ await api.put(`${interactionPrefix}/event`, {
api.put(`${interactionPrefix}/event`, { json: {
json: { event: InteractionEvent.Register,
event: InteractionEvent.Register, },
}, });
}),
api.patch(`${interactionPrefix}/profile`, { await api.patch(`${interactionPrefix}/profile`, {
json: { json: {
connectorId, connectorId,
}, },
}), });
]);
return api.post(`${interactionPrefix}/submit`).json<Response>(); return api.post(`${interactionPrefix}/submit`).json<Response>();
}; };
export const bindSocialRelatedUser = async (payload: SocialEmailPayload | SocialPhonePayload) => { export const bindSocialRelatedUser = async (payload: SocialEmailPayload | SocialPhonePayload) => {
await Promise.all([ await api.patch(`${interactionPrefix}/identifiers`, {
api.patch(`${interactionPrefix}/identifiers`, { json: payload,
json: payload, });
}),
api.patch(`${interactionPrefix}/profile`, { await api.patch(`${interactionPrefix}/profile`, {
json: { json: {
connectorId: payload.connectorId, connectorId: payload.connectorId,
}, },
}), });
]);
return api.post(`${interactionPrefix}/submit`).json<Response>(); return api.post(`${interactionPrefix}/submit`).json<Response>();
}; };
@ -208,18 +204,17 @@ export const bindSocialRelatedUser = async (payload: SocialEmailPayload | Social
export const linkWithSocial = async (connectorId: string) => { export const linkWithSocial = async (connectorId: string) => {
// Sign-in with pre-verified email/phone identifier instead and replace the email/phone profile with connectorId. // Sign-in with pre-verified email/phone identifier instead and replace the email/phone profile with connectorId.
await Promise.all([ await api.put(`${interactionPrefix}/event`, {
api.put(`${interactionPrefix}/event`, { json: {
json: { event: InteractionEvent.SignIn,
event: InteractionEvent.SignIn, },
}, });
}),
api.put(`${interactionPrefix}/profile`, { await api.put(`${interactionPrefix}/profile`, {
json: { json: {
connectorId, connectorId,
}, },
}), });
]);
return api.post(`${interactionPrefix}/submit`).json<Response>(); return api.post(`${interactionPrefix}/submit`).json<Response>();
}; };