mirror of
https://github.com/logto-io/logto.git
synced 2025-01-20 21:32:31 -05:00
refactor(ui): optimize api call stack (#2988)
This commit is contained in:
parent
4dfd86980c
commit
1d42077ab4
1 changed files with 52 additions and 47 deletions
|
@ -114,27 +114,29 @@ export const verifyForgotPasswordVerificationCodeIdentifier = async (
|
|||
};
|
||||
|
||||
export const signInWithVerifiedIdentifier = async () => {
|
||||
await api.delete(`${interactionPrefix}/profile`);
|
||||
|
||||
await api.put(`${interactionPrefix}/event`, {
|
||||
json: {
|
||||
event: InteractionEvent.SignIn,
|
||||
},
|
||||
});
|
||||
await Promise.all([
|
||||
api.delete(`${interactionPrefix}/profile`),
|
||||
api.put(`${interactionPrefix}/event`, {
|
||||
json: {
|
||||
event: InteractionEvent.SignIn,
|
||||
},
|
||||
}),
|
||||
]);
|
||||
|
||||
return api.post(`${interactionPrefix}/submit`).json<Response>();
|
||||
};
|
||||
|
||||
export const registerWithVerifiedIdentifier = async (payload: SendVerificationCodePayload) => {
|
||||
await api.put(`${interactionPrefix}/event`, {
|
||||
json: {
|
||||
event: InteractionEvent.Register,
|
||||
},
|
||||
});
|
||||
|
||||
await api.put(`${interactionPrefix}/profile`, {
|
||||
json: payload,
|
||||
});
|
||||
await Promise.all([
|
||||
api.put(`${interactionPrefix}/event`, {
|
||||
json: {
|
||||
event: InteractionEvent.Register,
|
||||
},
|
||||
}),
|
||||
api.put(`${interactionPrefix}/profile`, {
|
||||
json: payload,
|
||||
}),
|
||||
]);
|
||||
|
||||
return api.post(`${interactionPrefix}/submit`).json<Response>();
|
||||
};
|
||||
|
@ -172,31 +174,33 @@ export const signInWithSocial = async (payload: SocialConnectorPayload) => {
|
|||
};
|
||||
|
||||
export const registerWithVerifiedSocial = async (connectorId: string) => {
|
||||
await api.put(`${interactionPrefix}/event`, {
|
||||
json: {
|
||||
event: InteractionEvent.Register,
|
||||
},
|
||||
});
|
||||
|
||||
await api.patch(`${interactionPrefix}/profile`, {
|
||||
json: {
|
||||
connectorId,
|
||||
},
|
||||
});
|
||||
await Promise.all([
|
||||
api.put(`${interactionPrefix}/event`, {
|
||||
json: {
|
||||
event: InteractionEvent.Register,
|
||||
},
|
||||
}),
|
||||
api.patch(`${interactionPrefix}/profile`, {
|
||||
json: {
|
||||
connectorId,
|
||||
},
|
||||
}),
|
||||
]);
|
||||
|
||||
return api.post(`${interactionPrefix}/submit`).json<Response>();
|
||||
};
|
||||
|
||||
export const bindSocialRelatedUser = async (payload: SocialEmailPayload | SocialPhonePayload) => {
|
||||
await api.patch(`${interactionPrefix}/identifiers`, {
|
||||
json: payload,
|
||||
});
|
||||
|
||||
await api.patch(`${interactionPrefix}/profile`, {
|
||||
json: {
|
||||
connectorId: payload.connectorId,
|
||||
},
|
||||
});
|
||||
await Promise.all([
|
||||
api.patch(`${interactionPrefix}/identifiers`, {
|
||||
json: payload,
|
||||
}),
|
||||
api.patch(`${interactionPrefix}/profile`, {
|
||||
json: {
|
||||
connectorId: payload.connectorId,
|
||||
},
|
||||
}),
|
||||
]);
|
||||
|
||||
return api.post(`${interactionPrefix}/submit`).json<Response>();
|
||||
};
|
||||
|
@ -204,17 +208,18 @@ 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 api.put(`${interactionPrefix}/event`, {
|
||||
json: {
|
||||
event: InteractionEvent.SignIn,
|
||||
},
|
||||
});
|
||||
|
||||
await api.put(`${interactionPrefix}/profile`, {
|
||||
json: {
|
||||
connectorId,
|
||||
},
|
||||
});
|
||||
await Promise.all([
|
||||
api.put(`${interactionPrefix}/event`, {
|
||||
json: {
|
||||
event: InteractionEvent.SignIn,
|
||||
},
|
||||
}),
|
||||
api.put(`${interactionPrefix}/profile`, {
|
||||
json: {
|
||||
connectorId,
|
||||
},
|
||||
}),
|
||||
]);
|
||||
|
||||
return api.post(`${interactionPrefix}/submit`).json<Response>();
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue