Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 813489c67e |
@@ -22,19 +22,19 @@ const SidebarLogo = () => {
|
||||
{config.layoutType === 'dark-sidebar' ? (
|
||||
<img
|
||||
alt='Logo'
|
||||
src={toAbsoluteUrl('/media/logos/logo.png')}
|
||||
src={toAbsoluteUrl('/media/logos/default-dark.svg')}
|
||||
className='h-25px app-sidebar-logo-default'
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
<img
|
||||
alt='Logo'
|
||||
src={toAbsoluteUrl('/media/logos/logo.png')}
|
||||
src={toAbsoluteUrl('/media/logos/default.svg')}
|
||||
className='h-25px app-sidebar-logo-default theme-light-show'
|
||||
/>
|
||||
<img
|
||||
alt='Logo'
|
||||
src={toAbsoluteUrl('/media/logos/logo.png')}
|
||||
src={toAbsoluteUrl('/media/logos/default-dark.svg')}
|
||||
className='h-25px app-sidebar-logo-default theme-dark-show'
|
||||
/>
|
||||
</>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
|
||||
.auth-height {
|
||||
min-height: 100vh;
|
||||
.auth-gray {
|
||||
background-color: $gray-200;
|
||||
}
|
||||
@@ -1,10 +1,47 @@
|
||||
/* eslint-disable jsx-a11y/anchor-is-valid */
|
||||
import {useEffect} from 'react'
|
||||
import {useEffect, useState} from 'react'
|
||||
import {Outlet, Link} from 'react-router-dom'
|
||||
import {toAbsoluteUrl} from '../../../_res/helpers'
|
||||
|
||||
const AuthLayout = () => {
|
||||
//initial background color
|
||||
let [bgColor, setBgColor] = useState({
|
||||
backgroundImage: 'linear-gradient(70deg, #E6E7F9, #b4caed)'
|
||||
})
|
||||
|
||||
// function to determine background color
|
||||
let changeBgColor = () => {
|
||||
// let randomNum = Math.round(Math.random() * 3)
|
||||
let randomNum = Number(localStorage.getItem('bg-num'))
|
||||
if(randomNum){
|
||||
if(randomNum <= 1){
|
||||
setBgColor({
|
||||
backgroundImage: 'linear-gradient(70deg, #E6E7F9, #b4caed)'
|
||||
})
|
||||
localStorage.setItem('bg-num', '2')
|
||||
}else if(randomNum <= 2){
|
||||
setBgColor({
|
||||
backgroundImage: 'linear-gradient(70deg, #eee, #fff)'
|
||||
})
|
||||
localStorage.setItem('bg-num', '3')
|
||||
}else{
|
||||
setBgColor({
|
||||
backgroundImage: 'linear-gradient(70deg, #d5e1f5, #75a5f0)'
|
||||
})
|
||||
localStorage.setItem('bg-num', '1')
|
||||
}
|
||||
}else{
|
||||
setBgColor({
|
||||
backgroundImage: 'linear-gradient(70deg, #E6E7F9, #b4caed)'
|
||||
})
|
||||
localStorage.setItem('bg-num', '1')
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
changeBgColor() // calls the change color function after page loads
|
||||
|
||||
const root = document.getElementById('root')
|
||||
if (root) {
|
||||
root.style.height = '100%'
|
||||
@@ -17,13 +54,17 @@ const AuthLayout = () => {
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div className='d-flex flex-column flex-lg-row flex-column-fluid h-100'>
|
||||
<div className='d-flex flex-column flex-lg-row flex-column-fluid overflow-auto' style={{backgroundImage: `${bgColor.backgroundImage}`}}>
|
||||
{/* begin::Body */}
|
||||
<div className='d-flex flex-column flex-lg-row-fluid w-lg-50 p-10 order-2 order-lg-1'>
|
||||
<div className='d-flex flex-column flex-lg-row-fluid w-lg-50 p-10 order-2 order-lg-1 vh-100'>
|
||||
{/* begin::Form */}
|
||||
<div className='d-flex flex-center flex-column flex-lg-row-fluid'>
|
||||
<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::Wrapper */}
|
||||
<div className='w-lg-500px p-10'>
|
||||
<div className='auth-gray w-lg-500px p-10 shadow-lg rounded-sm'>
|
||||
<Outlet />
|
||||
</div>
|
||||
{/* end::Wrapper */}
|
||||
@@ -60,45 +101,53 @@ const AuthLayout = () => {
|
||||
|
||||
{/* begin::Aside */}
|
||||
<div
|
||||
className='d-flex flex-lg-row-fluid w-lg-50 bgi-size-cover bgi-position-center order-1 order-lg-2'
|
||||
style={{backgroundImage: `url(${toAbsoluteUrl('/media/misc/auth-bg.png')})`}}
|
||||
className='position-relative d-flex flex-lg-row-fluid w-lg-50 p-10 order-1 order-lg-2'
|
||||
>
|
||||
{/* begin::Content */}
|
||||
<div className='d-flex flex-column flex-center py-15 px-5 px-md-15 w-100'>
|
||||
<div className='position-relative d-flex flex-column flex-center px-5 px-md-15 w-100'>
|
||||
{/* begin::Logo */}
|
||||
<Link to='/' className='mb-12'>
|
||||
{/* <Link to='/' className='mb-12'>
|
||||
<img alt='Float Mobility' src={toAbsoluteUrl('/media/logos/logo.png')} className='h-35px' />
|
||||
</Link>
|
||||
</Link> */}
|
||||
{/* end::Logo */}
|
||||
|
||||
{/* begin::Image */}
|
||||
<img
|
||||
className='mx-auto w-275px w-md-50 w-xl-500px mb-10 mb-lg-20'
|
||||
src={toAbsoluteUrl('/media/misc/auth-screens.png')}
|
||||
{/* <img
|
||||
className='mx-auto w-350px w-md-50 w-xl-500px mb-10 mb-lg-20 rounded'
|
||||
src={toAbsoluteUrl('/media/misc/auth-bg-new.png')}
|
||||
alt=''
|
||||
/>
|
||||
{/* end::Image */}
|
||||
|
||||
{/* begin::Title */}
|
||||
<h1 className='text-white fs-2qx fw-bolder text-center mb-7'>
|
||||
Fast, Efficient and Productive
|
||||
</h1>
|
||||
{/* end::Title */}
|
||||
|
||||
{/* begin::Text */}
|
||||
<div className='text-white fs-base text-center'>
|
||||
In this kind of post,{' '}
|
||||
<a href='#' className='opacity-75-hover text-warning fw-bold me-1'>
|
||||
the blogger
|
||||
</a>
|
||||
introduces a person they’ve interviewed <br /> and provides some background information
|
||||
about
|
||||
<a href='#' className='opacity-75-hover text-warning fw-bold me-1'>
|
||||
the interviewee
|
||||
</a>
|
||||
and their <br /> work following this is a transcript of the interview.
|
||||
style={{boxShadow: '0px 0px 10px white'}}
|
||||
/> */}
|
||||
<div className='mx-auto w-75 w-xl-500px mb-10 mb-lg-20 rounded'>
|
||||
<img
|
||||
className='img-fluid rounded'
|
||||
src={toAbsoluteUrl('/media/misc/auth-bg-new.png')}
|
||||
alt=''
|
||||
// style={{boxShadow: '0px 0px 10px white'}}
|
||||
/>
|
||||
</div>
|
||||
{/* end::Text */}
|
||||
{/* end::Image */}
|
||||
<div className='w-100 w-md-75'>
|
||||
{/* begin::Title */}
|
||||
<h1 className='text-dark fs-2qx fw-bolder text-center mb-7'>
|
||||
Fast, Efficient and Productive
|
||||
</h1>
|
||||
{/* end::Title */}
|
||||
|
||||
{/* begin::Text */}
|
||||
{/* <div className='text-dark fs-base text-center'>
|
||||
In this kind of post,{' '}
|
||||
<a href='#' className='opacity-75-hover text-warning fw-bold me-1'>
|
||||
the blogger
|
||||
</a>
|
||||
introduces a person they’ve interviewed <br /> and provides some background information
|
||||
about {' '}
|
||||
<a href='#' className='opacity-75-hover text-warning fw-bold me-1'>
|
||||
the interviewee
|
||||
</a>
|
||||
and their <br /> work following this is a transcript of the interview.
|
||||
</div> */}
|
||||
{/* end::Text */}
|
||||
</div>
|
||||
</div>
|
||||
{/* end::Content */}
|
||||
</div>
|
||||
|
||||
@@ -50,12 +50,6 @@ 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'>
|
||||
|
||||
@@ -21,8 +21,8 @@ const loginSchema = Yup.object().shape({
|
||||
})
|
||||
|
||||
const initialValues = {
|
||||
email: '',
|
||||
password: '',
|
||||
email: 'demo@float.sg',
|
||||
password: '****',
|
||||
}
|
||||
//email: 'admin@demo.com',
|
||||
/*
|
||||
@@ -39,22 +39,12 @@ export function Login() {
|
||||
initialValues,
|
||||
validationSchema: loginSchema,
|
||||
onSubmit: async (values, {setStatus, setSubmitting}) => {
|
||||
setStatus('')
|
||||
setLoading(true)
|
||||
try {
|
||||
const {data: auth} = await login(values.email, values.password)
|
||||
// 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)
|
||||
console.log(auth) //remove later
|
||||
const {data: user} = await getUserByToken(auth.api_token)
|
||||
setCurrentUser(user)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
saveAuth(undefined)
|
||||
@@ -73,11 +63,6 @@ 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,12 +86,7 @@ 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 */}
|
||||
|
||||
@@ -69,12 +69,9 @@ const AuthInit: FC<WithChildren> = ({children}) => {
|
||||
const requestUser = async (apiToken: string) => {
|
||||
try {
|
||||
if (!didRequest.current) {
|
||||
// const {data} = await getUserByToken(apiToken)
|
||||
// if (data) {
|
||||
// setCurrentUser(data)
|
||||
// }
|
||||
if (localStorage.getItem('kt-auth-react-v')) {
|
||||
setCurrentUser(auth.profile)
|
||||
const {data} = await getUserByToken(apiToken)
|
||||
if (data) {
|
||||
setCurrentUser(data)
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -89,8 +86,8 @@ const AuthInit: FC<WithChildren> = ({children}) => {
|
||||
return () => (didRequest.current = true)
|
||||
}
|
||||
|
||||
if (auth && auth.session_token) {
|
||||
requestUser(auth.session_token)
|
||||
if (auth && auth.api_token) {
|
||||
requestUser(auth.api_token)
|
||||
} else {
|
||||
logout()
|
||||
setShowSplashScreen(false)
|
||||
|
||||
@@ -52,8 +52,8 @@ export function setupAxios(axios: any) {
|
||||
axios.interceptors.request.use(
|
||||
(config: {headers: {Authorization: string}}) => {
|
||||
const auth = getAuth()
|
||||
if (auth && auth.session_token) {
|
||||
config.headers.Authorization = `Bearer ${auth.session_token}`
|
||||
if (auth && auth.api_token) {
|
||||
config.headers.Authorization = `Bearer ${auth.api_token}`
|
||||
}
|
||||
|
||||
return config
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export interface AuthModel {
|
||||
session_token: string
|
||||
api_token: string
|
||||
refreshToken?: string
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import axios from 'axios'
|
||||
import {AuthModel, UserModel} from './_models'
|
||||
|
||||
const API_URL = process.env.REACT_APP_API_URL
|
||||
const API_URL = process?.env.REACT_APP_API_URL
|
||||
|
||||
export const GET_USER_BY_ACCESSTOKEN_URL = `${API_URL}/verify_token`
|
||||
export const LOGIN_URL = `${API_URL}/login`
|
||||
@@ -11,8 +11,8 @@ export const REQUEST_PASSWORD_URL = `${API_URL}/forgot_password`
|
||||
// Server should return AuthModel
|
||||
export function login(email: string, password: string) {
|
||||
return axios.post<AuthModel>(LOGIN_URL, {
|
||||
username: email,
|
||||
password: password,
|
||||
email,
|
||||
password,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ export function requestPassword(email: string) {
|
||||
}
|
||||
|
||||
export function getUserByToken(token: string) {
|
||||
return axios.get<UserModel>(GET_USER_BY_ACCESSTOKEN_URL, {
|
||||
session_token: token,
|
||||
return axios.post<UserModel>(GET_USER_BY_ACCESSTOKEN_URL, {
|
||||
api_token: token,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user