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'
|
id='kt_login_password_reset_form'
|
||||||
onSubmit={formik.handleSubmit}
|
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'>
|
<div className='text-center mb-10'>
|
||||||
{/* begin::Link */}
|
{/* begin::Link */}
|
||||||
<div className='text-gray-500 fw-semibold fs-6'>
|
<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 {toAbsoluteUrl} from '../../../../_metronic/helpers'
|
||||||
import {useAuth} from '../core/Auth'
|
import {useAuth} from '../core/Auth'
|
||||||
|
|
||||||
import {useNavigate} from 'react-router-dom'
|
|
||||||
|
|
||||||
const loginSchema = Yup.object().shape({
|
const loginSchema = Yup.object().shape({
|
||||||
email: Yup.string()
|
email: Yup.string()
|
||||||
.email('Wrong email format')
|
.email('Wrong email format')
|
||||||
@@ -34,7 +32,6 @@ const initialValues = {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export function Login() {
|
export function Login() {
|
||||||
const navigate = useNavigate()
|
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
const {saveAuth, setCurrentUser} = useAuth()
|
const {saveAuth, setCurrentUser} = useAuth()
|
||||||
|
|
||||||
@@ -42,14 +39,22 @@ export function Login() {
|
|||||||
initialValues,
|
initialValues,
|
||||||
validationSchema: loginSchema,
|
validationSchema: loginSchema,
|
||||||
onSubmit: async (values, {setStatus, setSubmitting}) => {
|
onSubmit: async (values, {setStatus, setSubmitting}) => {
|
||||||
|
setStatus('')
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
try {
|
try {
|
||||||
const {data: auth} = await login(values.email, values.password)
|
const {data: auth} = await login(values.email, values.password)
|
||||||
saveAuth(auth)
|
|
||||||
// const {data: user} = await getUserByToken(auth.session_token)
|
// const {data: user} = await getUserByToken(auth.session_token)
|
||||||
// setCurrentUser(user)
|
// 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)
|
setCurrentUser(auth.profile)
|
||||||
navigate('/dashboard')
|
console.log(auth) //remove later
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
saveAuth(undefined)
|
saveAuth(undefined)
|
||||||
@@ -68,6 +73,11 @@ export function Login() {
|
|||||||
id='kt_login_signin_form'
|
id='kt_login_signin_form'
|
||||||
>
|
>
|
||||||
{/* begin::Heading */}
|
{/* 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 */}
|
{/* begin::Login options */}
|
||||||
<div className='row g-3 mb-9'>
|
<div className='row g-3 mb-9'>
|
||||||
|
|||||||
@@ -86,7 +86,12 @@ export function Registration() {
|
|||||||
id='kt_login_signup_form'
|
id='kt_login_signup_form'
|
||||||
onSubmit={formik.handleSubmit}
|
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 */}
|
{/* begin::Login options */}
|
||||||
<div className='row g-3 mb-9'>
|
<div className='row g-3 mb-9'>
|
||||||
{/* begin::Col */}
|
{/* begin::Col */}
|
||||||
|
|||||||
Reference in New Issue
Block a user