mirror of
https://github.com/Unleash/unleash.git
synced 2025-06-09 01:17:06 +02:00
fix: "Reset password" page works when password authentication is disabled (#2126)
fix: password reset with only sso enabled show correct error message
This commit is contained in:
parent
0e4734af38
commit
df11ad9135
@ -11,14 +11,17 @@ import StandaloneLayout from '../common/StandaloneLayout/StandaloneLayout';
|
|||||||
import ResetPasswordForm from '../common/ResetPasswordForm/ResetPasswordForm';
|
import ResetPasswordForm from '../common/ResetPasswordForm/ResetPasswordForm';
|
||||||
import ResetPasswordError from '../common/ResetPasswordError/ResetPasswordError';
|
import ResetPasswordError from '../common/ResetPasswordError/ResetPasswordError';
|
||||||
import { useAuthResetPasswordApi } from 'hooks/api/actions/useAuthResetPasswordApi/useAuthResetPasswordApi';
|
import { useAuthResetPasswordApi } from 'hooks/api/actions/useAuthResetPasswordApi/useAuthResetPasswordApi';
|
||||||
|
import { useAuthDetails } from 'hooks/api/getters/useAuth/useAuthDetails';
|
||||||
|
|
||||||
const ResetPassword = () => {
|
const ResetPassword = () => {
|
||||||
const { classes: styles } = useStyles();
|
const { classes: styles } = useStyles();
|
||||||
const { token, loading, setLoading, isValidToken } = useResetPassword();
|
const { token, loading, isValidToken } = useResetPassword();
|
||||||
const { resetPassword, loading: actionLoading } = useAuthResetPasswordApi();
|
const { resetPassword, loading: actionLoading } = useAuthResetPasswordApi();
|
||||||
|
const { authDetails } = useAuthDetails();
|
||||||
const ref = useLoading(loading || actionLoading);
|
const ref = useLoading(loading || actionLoading);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [hasApiError, setHasApiError] = useState(false);
|
const [hasApiError, setHasApiError] = useState(false);
|
||||||
|
const passwordDisabled = authDetails?.defaultHidden === true;
|
||||||
|
|
||||||
const onSubmit = async (password: string) => {
|
const onSubmit = async (password: string) => {
|
||||||
try {
|
try {
|
||||||
@ -39,7 +42,7 @@ const ResetPassword = () => {
|
|||||||
<StandaloneLayout>
|
<StandaloneLayout>
|
||||||
<div className={styles.resetPassword}>
|
<div className={styles.resetPassword}>
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={!isValidToken}
|
condition={!isValidToken || passwordDisabled}
|
||||||
show={<InvalidToken />}
|
show={<InvalidToken />}
|
||||||
elseShow={
|
elseShow={
|
||||||
<>
|
<>
|
||||||
|
Loading…
Reference in New Issue
Block a user