login layout reverted and login function cleaned up
This commit is contained in:
@@ -50,6 +50,12 @@ export function ForgotPassword() {
|
||||
id='kt_login_password_reset_form'
|
||||
onSubmit={formik.handleSubmit}
|
||||
>
|
||||
{/* begin::Heading */}
|
||||
<div className='text-center mb-11'>
|
||||
{/* <h1 className='text-dark fw-bolder mb-3'>Sign In</h1> */}
|
||||
<img alt='Float Mobility' src={toAbsoluteUrl('/media/logos/logo.png')} className='h-35px' />
|
||||
</div>
|
||||
{/* begin::Heading */}
|
||||
<div className='text-center mb-10'>
|
||||
{/* begin::Link */}
|
||||
<div className='text-gray-500 fw-semibold fs-6'>
|
||||
|
||||
@@ -8,8 +8,6 @@ import {getUserByToken, login} from '../core/_requests'
|
||||
import {toAbsoluteUrl} from '../../../../_metronic/helpers'
|
||||
import {useAuth} from '../core/Auth'
|
||||
|
||||
import {useNavigate} from 'react-router-dom'
|
||||
|
||||
const loginSchema = Yup.object().shape({
|
||||
email: Yup.string()
|
||||
.email('Wrong email format')
|
||||
@@ -34,7 +32,6 @@ const initialValues = {
|
||||
*/
|
||||
|
||||
export function Login() {
|
||||
const navigate = useNavigate()
|
||||
const [loading, setLoading] = useState(false)
|
||||
const {saveAuth, setCurrentUser} = useAuth()
|
||||
|
||||
@@ -42,14 +39,22 @@ export function Login() {
|
||||
initialValues,
|
||||
validationSchema: loginSchema,
|
||||
onSubmit: async (values, {setStatus, setSubmitting}) => {
|
||||
setStatus('')
|
||||
setLoading(true)
|
||||
try {
|
||||
const {data: auth} = await login(values.email, values.password)
|
||||
saveAuth(auth)
|
||||
// const {data: user} = await getUserByToken(auth.session_token)
|
||||
// setCurrentUser(user)
|
||||
if(auth.status <= 0){ // checking if request is not successful
|
||||
setStatus('The login details are incorrect')
|
||||
setSubmitting(false)
|
||||
setLoading(false)
|
||||
console.log(auth) //remove later
|
||||
return
|
||||
}
|
||||
saveAuth(auth)
|
||||
setCurrentUser(auth.profile)
|
||||
navigate('/dashboard')
|
||||
console.log(auth) //remove later
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
saveAuth(undefined)
|
||||
@@ -68,6 +73,11 @@ export function Login() {
|
||||
id='kt_login_signin_form'
|
||||
>
|
||||
{/* begin::Heading */}
|
||||
<div className='text-center mb-11'>
|
||||
{/* <h1 className='text-dark fw-bolder mb-3'>Sign In</h1> */}
|
||||
<img alt='Float Mobility' src={toAbsoluteUrl('/media/logos/logo.png')} className='h-35px' />
|
||||
</div>
|
||||
{/* begin::Heading */}
|
||||
|
||||
{/* begin::Login options */}
|
||||
<div className='row g-3 mb-9'>
|
||||
|
||||
@@ -86,7 +86,12 @@ export function Registration() {
|
||||
id='kt_login_signup_form'
|
||||
onSubmit={formik.handleSubmit}
|
||||
>
|
||||
|
||||
{/* begin::Heading */}
|
||||
<div className='text-center mb-11'>
|
||||
{/* <h1 className='text-dark fw-bolder mb-3'>Sign In</h1> */}
|
||||
<img alt='Float Mobility' src={toAbsoluteUrl('/media/logos/logo.png')} className='h-35px' />
|
||||
</div>
|
||||
{/* begin::Heading */}
|
||||
{/* begin::Login options */}
|
||||
<div className='row g-3 mb-9'>
|
||||
{/* begin::Col */}
|
||||
|
||||
Reference in New Issue
Block a user