diff --git a/src/pages/authentication/ForgotPassword/AuthCallback/index.js b/src/pages/authentication/ForgotPassword/AuthCallback/index.js index 9a17543..0a636a6 100644 --- a/src/pages/authentication/ForgotPassword/AuthCallback/index.js +++ b/src/pages/authentication/ForgotPassword/AuthCallback/index.js @@ -33,6 +33,7 @@ import { EyeInvisibleOutlined, EyeOutlined } from '@ant-design/icons'; import axios from 'axios'; import { useParams,Link } from 'react-router-dom'; import CancelOutlinedIcon from '@mui/icons-material/CancelOutlined'; +import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined'; // ==============================|| DASHBOARD - DEFAULT ||============================== // @@ -43,6 +44,7 @@ const Index = () => { const [showPassword, setShowPassword] = React.useState(false); const [showConfirmPassword, setshowConfirmPassword] = React.useState(false); const [isLoading, setLoding] = React.useState(true); + /** null: loading; true: verified (show password form); false: link invalid/already used (HTTP 200, no username); 'error': network / server error */ const [verifyState, setVerifyState] = React.useState(null) const [enterUseEffect, setEnterUseEffect] = React.useState(false) const [username, setUsername] = React.useState("") @@ -75,14 +77,16 @@ const Index = () => { console.log(response) setUsername(response.data.username) setVerifyState(true) - } else { + } else if (response.status === 200) { setVerifyState(false) + } else { + setVerifyState('error') } setLoding(false) } ).catch(error => { console.log(error) - setVerifyState(false) + setVerifyState('error') setLoding(false) }); @@ -215,7 +219,7 @@ const Index = () => { boxShadow >
- {verifyState ? + {verifyState === true ? // SUCCESS page @@ -387,8 +391,27 @@ const Index = () => { + : verifyState === false ? + // Link invalid or already used (same as Verify.js informational branch) + + + + + + + + + + + + + : - // ERROR page + // ERROR page (network / server error) diff --git a/src/pages/authentication/Verify.js b/src/pages/authentication/Verify.js index a3fd629..81c439d 100644 --- a/src/pages/authentication/Verify.js +++ b/src/pages/authentication/Verify.js @@ -36,9 +36,11 @@ export default function Verify() { } } ).then( (response)=>{ + // Same idea as forgot-password: only strict true = success. Any other 200 (false, null, + // or link already consumed so hash no longer matches) = informational, not failure. if (response.status === 200 && response.data === true) { setVerifyState(true) - } else if (response.status === 200 && response.data === false) { + } else if (response.status === 200) { setVerifyState(false) } else { setVerifyState('error')