mirror of
https://github.com/logto-io/logto.git
synced 2025-02-03 21:48:55 -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 () => {
|
export const signInWithVerifiedIdentifier = async () => {
|
||||||
await api.delete(`${interactionPrefix}/profile`);
|
await Promise.all([
|
||||||
|
api.delete(`${interactionPrefix}/profile`),
|
||||||
await api.put(`${interactionPrefix}/event`, {
|
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 api.put(`${interactionPrefix}/event`, {
|
await Promise.all([
|
||||||
json: {
|
api.put(`${interactionPrefix}/event`, {
|
||||||
event: InteractionEvent.Register,
|
json: {
|
||||||
},
|
event: InteractionEvent.Register,
|
||||||
});
|
},
|
||||||
|
}),
|
||||||
await api.put(`${interactionPrefix}/profile`, {
|
api.put(`${interactionPrefix}/profile`, {
|
||||||
json: payload,
|
json: payload,
|
||||||
});
|
}),
|
||||||
|
]);
|
||||||
|
|
||||||
return api.post(`${interactionPrefix}/submit`).json<Response>();
|
return api.post(`${interactionPrefix}/submit`).json<Response>();
|
||||||
};
|
};
|
||||||
|
@ -172,31 +174,33 @@ export const signInWithSocial = async (payload: SocialConnectorPayload) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const registerWithVerifiedSocial = async (connectorId: string) => {
|
export const registerWithVerifiedSocial = async (connectorId: string) => {
|
||||||
await api.put(`${interactionPrefix}/event`, {
|
await Promise.all([
|
||||||
json: {
|
api.put(`${interactionPrefix}/event`, {
|
||||||
event: InteractionEvent.Register,
|
json: {
|
||||||
},
|
event: InteractionEvent.Register,
|
||||||
});
|
},
|
||||||
|
}),
|
||||||
await api.patch(`${interactionPrefix}/profile`, {
|
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 api.patch(`${interactionPrefix}/identifiers`, {
|
await Promise.all([
|
||||||
json: payload,
|
api.patch(`${interactionPrefix}/identifiers`, {
|
||||||
});
|
json: payload,
|
||||||
|
}),
|
||||||
await api.patch(`${interactionPrefix}/profile`, {
|
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>();
|
||||||
};
|
};
|
||||||
|
@ -204,17 +208,18 @@ 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 api.put(`${interactionPrefix}/event`, {
|
await Promise.all([
|
||||||
json: {
|
api.put(`${interactionPrefix}/event`, {
|
||||||
event: InteractionEvent.SignIn,
|
json: {
|
||||||
},
|
event: InteractionEvent.SignIn,
|
||||||
});
|
},
|
||||||
|
}),
|
||||||
await api.put(`${interactionPrefix}/profile`, {
|
api.put(`${interactionPrefix}/profile`, {
|
||||||
json: {
|
json: {
|
||||||
connectorId,
|
connectorId,
|
||||||
},
|
},
|
||||||
});
|
}),
|
||||||
|
]);
|
||||||
|
|
||||||
return api.post(`${interactionPrefix}/submit`).json<Response>();
|
return api.post(`${interactionPrefix}/submit`).json<Response>();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue