Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c17f95351f | |||
| 9103a812b5 | |||
| 7dc8503861 | |||
| a819bcca1f | |||
| 161bac928b | |||
| 40834b9c38 | |||
| 7a823fcf74 | |||
| faa4fdf8a6 | |||
| a33d405c8c | |||
| 56570fbd33 | |||
| 2d657165bd | |||
| 7daf939239 |
@@ -2,7 +2,7 @@ PUBLIC_URL=http://localhost:3000/
|
||||
PORT=3000
|
||||
PRIMARY_APP_API_URL=https://preview.keenthemes.com/metronic8/laravel/api
|
||||
REACT_APP_BASE_LAYOUT_CONFIG_KEY='metronic-react-demo1-8150'
|
||||
REACT_APP_API_URL=https://preview.keenthemes.com/metronic8/laravel/api
|
||||
REACT_APP_API_URL=https://float-gat.dev.chiefsoft.net/en/userweb/api/v1
|
||||
REACT_APP_VERSION=v8.1.5
|
||||
REACT_APP_THEME_NAME=WrenchBoard
|
||||
REACT_APP_THEME_DEMO=dashboard
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
|
||||
<div id="root"></div>
|
||||
<div id="splash-screen" class="splash-screen">
|
||||
<img src="%PUBLIC_URL%/media/logos/default-small.svg" alt="WrenchBoard" />
|
||||
<img src="%PUBLIC_URL%/media/logos/favicon.ico" alt="Float Users" />
|
||||
<span>Loading ...</span>
|
||||
</div>
|
||||
<div id="root-modals"></div>
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
.auth-gray {
|
||||
background-color: $gray-200;
|
||||
}
|
||||
@@ -12,4 +12,5 @@
|
||||
@import "header/header-sidebar-light";
|
||||
@import "content";
|
||||
@import "toolbar";
|
||||
@import "page-title";
|
||||
@import "page-title";
|
||||
@import "auth";
|
||||
@@ -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,7 +54,7 @@ const AuthLayout = () => {
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div className='d-flex flex-column flex-lg-row flex-column-fluid overflow-auto'>
|
||||
<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 vh-100'>
|
||||
{/* begin::Form */}
|
||||
@@ -27,7 +64,7 @@ const AuthLayout = () => {
|
||||
<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 */}
|
||||
@@ -65,23 +102,29 @@ const AuthLayout = () => {
|
||||
{/* begin::Aside */}
|
||||
<div
|
||||
className='position-relative d-flex flex-lg-row-fluid w-lg-50 p-10 order-1 order-lg-2'
|
||||
// style={{backgroundImage: `url(${toAbsoluteUrl('/media/misc/auth-bg.png')})`}}
|
||||
style={{backgroundColor: '#E6E7F9'}}
|
||||
>
|
||||
{/* begin::Content */}
|
||||
<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 */}
|
||||
|
||||
<img
|
||||
{/* <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=''
|
||||
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::Image */}
|
||||
<div className='w-100 w-md-75'>
|
||||
{/* begin::Title */}
|
||||
@@ -91,7 +134,7 @@ const AuthLayout = () => {
|
||||
{/* end::Title */}
|
||||
|
||||
{/* begin::Text */}
|
||||
<div className='text-dark fs-base text-center'>
|
||||
{/* <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
|
||||
@@ -102,7 +145,7 @@ const AuthLayout = () => {
|
||||
the interviewee
|
||||
</a>
|
||||
and their <br /> work following this is a transcript of the interview.
|
||||
</div>
|
||||
</div> */}
|
||||
{/* end::Text */}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -8,6 +8,8 @@ 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')
|
||||
@@ -21,10 +23,10 @@ const loginSchema = Yup.object().shape({
|
||||
})
|
||||
|
||||
const initialValues = {
|
||||
email: 'admin@demo.com',
|
||||
password: 'demo',
|
||||
email: 'demo@float.sg',
|
||||
password: '****',
|
||||
}
|
||||
|
||||
//email: 'admin@demo.com',
|
||||
/*
|
||||
Formik+YUP+Typescript:
|
||||
https://jaredpalmer.com/formik/docs/tutorial#getfieldprops
|
||||
@@ -32,6 +34,7 @@ const initialValues = {
|
||||
*/
|
||||
|
||||
export function Login() {
|
||||
const navigate = useNavigate()
|
||||
const [loading, setLoading] = useState(false)
|
||||
const {saveAuth, setCurrentUser} = useAuth()
|
||||
|
||||
@@ -42,9 +45,13 @@ export function Login() {
|
||||
setLoading(true)
|
||||
try {
|
||||
const {data: auth} = await login(values.email, values.password)
|
||||
console.log('yes')
|
||||
saveAuth(auth)
|
||||
const {data: user} = await getUserByToken(auth.api_token)
|
||||
setCurrentUser(user)
|
||||
// const {data: user} = await getUserByToken(auth.session_token)
|
||||
console.log('yes2')
|
||||
// setCurrentUser(user)
|
||||
setCurrentUser(auth.profile)
|
||||
navigate('/dashboard')
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
saveAuth(undefined)
|
||||
|
||||
@@ -309,7 +309,7 @@ export function Registration() {
|
||||
<span>
|
||||
I Accept the{' '}
|
||||
<a
|
||||
href='https://keenthemes.com/metronic/?page=faq'
|
||||
href='#'
|
||||
target='_blank'
|
||||
className='ms-1 link-primary'
|
||||
>
|
||||
|
||||
@@ -77,7 +77,7 @@ const AuthInit: FC<WithChildren> = ({children}) => {
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
if (!didRequest.current) {
|
||||
logout()
|
||||
// logout()
|
||||
}
|
||||
} finally {
|
||||
setShowSplashScreen(false)
|
||||
@@ -86,8 +86,8 @@ const AuthInit: FC<WithChildren> = ({children}) => {
|
||||
return () => (didRequest.current = true)
|
||||
}
|
||||
|
||||
if (auth && auth.api_token) {
|
||||
requestUser(auth.api_token)
|
||||
if (auth && auth.session_token) {
|
||||
requestUser(auth.session_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.api_token) {
|
||||
config.headers.Authorization = `Bearer ${auth.api_token}`
|
||||
if (auth && auth.session_token) {
|
||||
config.headers.Authorization = `Bearer ${auth.session_token}`
|
||||
}
|
||||
|
||||
return config
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export interface AuthModel {
|
||||
api_token: string
|
||||
session_token: string
|
||||
refreshToken?: string
|
||||
}
|
||||
|
||||
|
||||
@@ -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, {
|
||||
email,
|
||||
password,
|
||||
username: email,
|
||||
password: password,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ export function requestPassword(email: string) {
|
||||
}
|
||||
|
||||
export function getUserByToken(token: string) {
|
||||
return axios.post<UserModel>(GET_USER_BY_ACCESSTOKEN_URL, {
|
||||
api_token: token,
|
||||
return axios.get<UserModel>(GET_USER_BY_ACCESSTOKEN_URL, {
|
||||
session_token: token,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user