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

fix(experience): avoid carring identifer from reset password page to sign-in page (#6526)

This commit is contained in:
Xiao Yijun 2024-08-28 13:46:48 +08:00 committed by GitHub
parent aba089285b
commit 347cd3b6b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -21,13 +21,7 @@ const ResetPassword = () => {
const { setToast } = useToast();
const navigate = useNavigate();
const { show } = usePromiseConfirmModal();
const {
identifierInputValue,
setIdentifierInputValue,
forgotPasswordIdentifierInputValue,
setForgotPasswordIdentifierInputValue,
} = useContext(UserInteractionContext);
const { setForgotPasswordIdentifierInputValue } = useContext(UserInteractionContext);
const errorHandlers: ErrorHandlers = useMemo(
() => ({
'session.verification_session_not_found': async (error) => {
@ -43,15 +37,6 @@ const ResetPassword = () => {
const successHandler: SuccessHandler<typeof setUserPassword> = useCallback(
(result) => {
if (result) {
/**
* Improve user experience by caching the identifier input value for sign-in page
* when the user is first redirected to the reset password page.
* This allows user to continue the sign flow without having to re-enter the identifier.
*/
if (!identifierInputValue) {
setIdentifierInputValue(forgotPasswordIdentifierInputValue);
}
// Clear the forgot password identifier input value after the password is set
setForgotPasswordIdentifierInputValue(undefined);
@ -59,15 +44,7 @@ const ResetPassword = () => {
navigate('/sign-in', { replace: true });
}
},
[
forgotPasswordIdentifierInputValue,
identifierInputValue,
navigate,
setForgotPasswordIdentifierInputValue,
setIdentifierInputValue,
setToast,
t,
]
[navigate, setForgotPasswordIdentifierInputValue, setToast, t]
);
const [action] = usePasswordAction({