0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-30 20:33:54 -05:00

fix(experience): update some namings

update some namings
This commit is contained in:
simeng-li 2024-08-14 15:43:01 +08:00
parent 9cf32258ff
commit a0fbd7fcf1
No known key found for this signature in database
GPG key ID: 14EA7BB1541E8075
3 changed files with 11 additions and 10 deletions

View file

@ -10,9 +10,10 @@ import api from './api';
const prefix = '/api/experience'; const prefix = '/api/experience';
const experienceRoutes = Object.freeze({ const experienceApiRoutes = Object.freeze({
prefix, prefix,
identification: `${prefix}/identification`, identification: `${prefix}/identification`,
submit: `${prefix}/submit`,
verification: `${prefix}/verification`, verification: `${prefix}/verification`,
profile: `${prefix}/profile`, profile: `${prefix}/profile`,
mfa: `${prefix}/profile/mfa`, mfa: `${prefix}/profile/mfa`,
@ -27,27 +28,27 @@ type SubmitInteractionResponse = {
}; };
const initInteraction = async (interactionEvent: InteractionEvent) => const initInteraction = async (interactionEvent: InteractionEvent) =>
api.put(`${experienceRoutes.prefix}`, { api.put(`${experienceApiRoutes.prefix}`, {
json: { json: {
interactionEvent, interactionEvent,
}, },
}); });
const identifyUser = async (payload: IdentificationApiPayload = {}) => const identifyUser = async (payload: IdentificationApiPayload = {}) =>
api.post(experienceRoutes.identification, { json: payload }); api.post(experienceApiRoutes.identification, { json: payload });
const submitInteraction = async () => const submitInteraction = async () =>
api.post(`${experienceRoutes.prefix}/submit`).json<SubmitInteractionResponse>(); api.post(`${experienceApiRoutes.submit}`).json<SubmitInteractionResponse>();
const updateProfile = async (payload: UpdateProfileApiPayload) => { const updateProfile = async (payload: UpdateProfileApiPayload) => {
await api.post(experienceRoutes.profile, { json: payload }); await api.post(experienceApiRoutes.profile, { json: payload });
}; };
export const signInWithPasswordIdentifier = async (payload: PasswordVerificationPayload) => { export const signInWithPasswordIdentifier = async (payload: PasswordVerificationPayload) => {
await initInteraction(InteractionEvent.SignIn); await initInteraction(InteractionEvent.SignIn);
const { verificationId } = await api const { verificationId } = await api
.post(`${experienceRoutes.verification}/password`, { .post(`${experienceApiRoutes.verification}/password`, {
json: payload, json: payload,
}) })
.json<VerificationResponse>(); .json<VerificationResponse>();

View file

@ -3,11 +3,11 @@ import { useCallback } from 'react';
import usePasswordErrorMessage from './use-password-error-message'; import usePasswordErrorMessage from './use-password-error-message';
import { usePasswordPolicy } from './use-sie'; import { usePasswordPolicy } from './use-sie';
type PasswordPolicyCheckProps = { type Options = {
setErrorMessage: (message?: string) => void; setErrorMessage: (message?: string) => void;
}; };
const usePasswordPolicyChecker = ({ setErrorMessage }: PasswordPolicyCheckProps) => { const usePasswordPolicyChecker = ({ setErrorMessage }: Options) => {
const { getErrorMessage } = usePasswordErrorMessage(); const { getErrorMessage } = usePasswordErrorMessage();
const { policyChecker } = usePasswordPolicy(); const { policyChecker } = usePasswordPolicy();

View file

@ -4,11 +4,11 @@ import { useCallback, useMemo } from 'react';
import type { ErrorHandlers } from './use-error-handler'; import type { ErrorHandlers } from './use-error-handler';
import usePasswordErrorMessage from './use-password-error-message'; import usePasswordErrorMessage from './use-password-error-message';
type ErrorHandlerProps = { type Options = {
setErrorMessage: (message?: string) => void; setErrorMessage: (message?: string) => void;
}; };
const usePasswordRejectionErrorHandler = ({ setErrorMessage }: ErrorHandlerProps) => { const usePasswordRejectionErrorHandler = ({ setErrorMessage }: Options) => {
const { getErrorMessageFromBody } = usePasswordErrorMessage(); const { getErrorMessageFromBody } = usePasswordErrorMessage();
const passwordRejectionHandler = useCallback( const passwordRejectionHandler = useCallback(