Merge branch 'login-error-msg-timeout' of FloatSystems/float-fleet into master
This commit is contained in:
@@ -18,4 +18,5 @@ REACT_APP_TERMS_LINK='https://www.float.sg/terms'
|
||||
REACT_APP_CONTACT_LINK='https://www.float.sg/contact'
|
||||
REACT_APP_ABOUT_LINK='https://www.float.sg/about'
|
||||
|
||||
REACT_APP_LOGOUT_SESSION_TIMEOUT=300000
|
||||
REACT_APP_LOGIN_ERROR_TIMEOUT=5000
|
||||
REACT_APP_LOGOUT_SESSION_TIMEOUT=300000
|
||||
|
||||
@@ -37,6 +37,7 @@ export function Login() {
|
||||
const navigate = useNavigate()
|
||||
const [loading, setLoading] = useState(false)
|
||||
const {saveAuth, setCurrentUser} = useAuth()
|
||||
const statusChecker = document.getElementById('formik-status')
|
||||
|
||||
const formik = useFormik({
|
||||
initialValues,
|
||||
@@ -48,14 +49,25 @@ export function Login() {
|
||||
saveAuth(auth)
|
||||
// const {data: user} = await getUserByToken(auth.api_token)
|
||||
// setCurrentUser(user)
|
||||
if(auth.status <= 0){
|
||||
setStatus(auth.error_msg)
|
||||
setSubmitting(false)
|
||||
setLoading(false)
|
||||
return
|
||||
}
|
||||
setCurrentUser(auth.profile)
|
||||
console.log(auth)
|
||||
navigate('/dashboard')
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
saveAuth(undefined)
|
||||
setStatus('The login details are incorrect')
|
||||
setStatus('An error occurred')
|
||||
setSubmitting(false)
|
||||
setLoading(false)
|
||||
} finally {
|
||||
setTimeout(() => {
|
||||
setStatus(null)
|
||||
}, Number(process.env.REACT_APP_LOGIN_ERROR_TIMEOUT))
|
||||
}
|
||||
},
|
||||
})
|
||||
@@ -126,7 +138,7 @@ export function Login() {
|
||||
{/* end::Separator */}
|
||||
|
||||
{formik.status ? (
|
||||
<div className='mb-lg-15 alert alert-danger'>
|
||||
<div id='formik-status' className='mb-lg-15 alert alert-danger'>
|
||||
<div className='alert-text font-weight-bold'>{formik.status}</div>
|
||||
</div>
|
||||
) : (
|
||||
@@ -163,7 +175,7 @@ export function Login() {
|
||||
<label className='form-label fw-bolder text-dark fs-6 mb-0'>Password</label>
|
||||
<input
|
||||
type='password'
|
||||
placeHolder="●●●●●●"
|
||||
placeholder="●●●●●●"
|
||||
autoComplete='off'
|
||||
{...formik.getFieldProps('password')}
|
||||
className={clsx(
|
||||
|
||||
Reference in New Issue
Block a user