Compare commits
30 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 33793a6f7b | |||
| 77532b6236 | |||
| bdb69ae30f | |||
| 57e6d17e3f | |||
| 0d20792924 | |||
| 55d1b5cbea | |||
| f045ebcfe4 | |||
| 94f2354785 | |||
| 2ae9b73613 | |||
| accace3f60 | |||
| c49cc64196 | |||
| 6a266ff772 | |||
| 4fcd3104df | |||
| bfc956137f | |||
| b4ddd86bc2 | |||
| f41a9961ae | |||
| 9376f96543 | |||
| 500c54d442 | |||
| 85bd79a612 | |||
| c17f95351f | |||
| 1be78e7484 | |||
| 9103a812b5 | |||
| 7dc8503861 | |||
| a819bcca1f | |||
| 161bac928b | |||
| 40834b9c38 | |||
| 7a823fcf74 | |||
| faa4fdf8a6 | |||
| a33d405c8c | |||
| 56570fbd33 |
@@ -2,7 +2,7 @@ PUBLIC_URL=http://localhost:3000/
|
|||||||
PORT=3000
|
PORT=3000
|
||||||
PRIMARY_APP_API_URL=https://preview.keenthemes.com/metronic8/laravel/api
|
PRIMARY_APP_API_URL=https://preview.keenthemes.com/metronic8/laravel/api
|
||||||
REACT_APP_BASE_LAYOUT_CONFIG_KEY='metronic-react-demo1-8150'
|
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_VERSION=v8.1.5
|
||||||
REACT_APP_THEME_NAME=WrenchBoard
|
REACT_APP_THEME_NAME=WrenchBoard
|
||||||
REACT_APP_THEME_DEMO=dashboard
|
REACT_APP_THEME_DEMO=dashboard
|
||||||
@@ -18,3 +18,6 @@ REACT_APP_THEME_API_URL=https://preview.keenthemes.com/theme-api/api
|
|||||||
REACT_APP_SITE_CONTACT_US=https://www.float.sg/contact
|
REACT_APP_SITE_CONTACT_US=https://www.float.sg/contact
|
||||||
REACT_APP_SITE_TERMS=https://www.float.sg/terms
|
REACT_APP_SITE_TERMS=https://www.float.sg/terms
|
||||||
REACT_APP_SITE_ABOUT_US=https://www.float.sg/about
|
REACT_APP_SITE_ABOUT_US=https://www.float.sg/about
|
||||||
|
|
||||||
|
REACT_APP_LOGIN_ERROR_TIMEOUT=5000
|
||||||
|
REACT_APP_SESSION_TIMEOUT=300000
|
||||||
|
|||||||
+1
-1
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
<div id="splash-screen" class="splash-screen">
|
<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>
|
<span>Loading ...</span>
|
||||||
</div>
|
</div>
|
||||||
<div id="root-modals"></div>
|
<div id="root-modals"></div>
|
||||||
|
|||||||
@@ -22,19 +22,19 @@ const SidebarLogo = () => {
|
|||||||
{config.layoutType === 'dark-sidebar' ? (
|
{config.layoutType === 'dark-sidebar' ? (
|
||||||
<img
|
<img
|
||||||
alt='Logo'
|
alt='Logo'
|
||||||
src={toAbsoluteUrl('/media/logos/default-dark.svg')}
|
src={toAbsoluteUrl('/media/logos/logo.png')}
|
||||||
className='h-25px app-sidebar-logo-default'
|
className='h-25px app-sidebar-logo-default'
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<img
|
<img
|
||||||
alt='Logo'
|
alt='Logo'
|
||||||
src={toAbsoluteUrl('/media/logos/default.svg')}
|
src={toAbsoluteUrl('/media/logos/logo.png')}
|
||||||
className='h-25px app-sidebar-logo-default theme-light-show'
|
className='h-25px app-sidebar-logo-default theme-light-show'
|
||||||
/>
|
/>
|
||||||
<img
|
<img
|
||||||
alt='Logo'
|
alt='Logo'
|
||||||
src={toAbsoluteUrl('/media/logos/default-dark.svg')}
|
src={toAbsoluteUrl('/media/logos/logo.png')}
|
||||||
className='h-25px app-sidebar-logo-default theme-dark-show'
|
className='h-25px app-sidebar-logo-default theme-dark-show'
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
.auth-height {
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
@@ -13,3 +13,4 @@
|
|||||||
@import "content";
|
@import "content";
|
||||||
@import "toolbar";
|
@import "toolbar";
|
||||||
@import "page-title";
|
@import "page-title";
|
||||||
|
@import "auth";
|
||||||
@@ -1,47 +1,10 @@
|
|||||||
/* eslint-disable jsx-a11y/anchor-is-valid */
|
/* eslint-disable jsx-a11y/anchor-is-valid */
|
||||||
import {useEffect, useState} from 'react'
|
import {useEffect} from 'react'
|
||||||
import {Outlet, Link} from 'react-router-dom'
|
import {Outlet, Link} from 'react-router-dom'
|
||||||
import {toAbsoluteUrl} from '../../../_res/helpers'
|
import {toAbsoluteUrl} from '../../../_res/helpers'
|
||||||
|
|
||||||
const AuthLayout = () => {
|
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(() => {
|
useEffect(() => {
|
||||||
|
|
||||||
changeBgColor() // calls the change color function after page loads
|
|
||||||
|
|
||||||
const root = document.getElementById('root')
|
const root = document.getElementById('root')
|
||||||
if (root) {
|
if (root) {
|
||||||
root.style.height = '100%'
|
root.style.height = '100%'
|
||||||
@@ -54,15 +17,11 @@ const AuthLayout = () => {
|
|||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
return (
|
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={{minHeight: '100vh'}}>
|
||||||
{/* begin::Body */}
|
{/* begin::Body */}
|
||||||
<div className='d-flex flex-column flex-lg-row-fluid w-lg-50 p-10 order-2 order-lg-1 vh-100'>
|
<div className='d-flex flex-column flex-lg-row-fluid w-lg-50 p-10 order-2 order-lg-1'>
|
||||||
{/* begin::Form */}
|
{/* begin::Form */}
|
||||||
<div className='d-flex flex-center flex-column flex-lg-row-fluid'>
|
<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 */}
|
{/* begin::Wrapper */}
|
||||||
<div className='w-lg-500px p-10'>
|
<div className='w-lg-500px p-10'>
|
||||||
<Outlet />
|
<Outlet />
|
||||||
@@ -101,47 +60,39 @@ const AuthLayout = () => {
|
|||||||
|
|
||||||
{/* begin::Aside */}
|
{/* begin::Aside */}
|
||||||
<div
|
<div
|
||||||
className='position-relative d-flex flex-lg-row-fluid w-lg-50 p-10 order-1 order-lg-2'
|
className='d-flex flex-lg-row-fluid w-lg-50 bgi-size-cover bgi-position-center order-1 order-lg-2'
|
||||||
style={{backgroundImage: `${bgColor.backgroundImage}`}}
|
style={{backgroundImage: `url(${toAbsoluteUrl('/media/misc/auth-bg.png')})`}}
|
||||||
>
|
>
|
||||||
{/* begin::Content */}
|
{/* begin::Content */}
|
||||||
<div className='position-relative d-flex flex-column flex-center px-5 px-md-15 w-100'>
|
<div className='d-flex flex-column flex-center py-15 px-5 px-md-15 w-100'>
|
||||||
{/* begin::Logo */}
|
{/* 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' />
|
<img alt='Float Mobility' src={toAbsoluteUrl('/media/logos/logo.png')} className='h-35px' />
|
||||||
</Link>
|
</Link>
|
||||||
{/* end::Logo */}
|
{/* end::Logo */}
|
||||||
|
|
||||||
{/* <img
|
{/* begin::Image */}
|
||||||
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
|
<img
|
||||||
className='img-fluid rounded'
|
className='mx-auto w-275px w-md-50 w-xl-500px mb-10 mb-lg-20'
|
||||||
src={toAbsoluteUrl('/media/misc/auth-bg-new.png')}
|
src={toAbsoluteUrl('/media/misc/auth-screens.png')}
|
||||||
alt=''
|
alt=''
|
||||||
style={{boxShadow: '0px 0px 10px white'}}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
{/* end::Image */}
|
{/* end::Image */}
|
||||||
<div className='w-100 w-md-75'>
|
|
||||||
{/* begin::Title */}
|
{/* begin::Title */}
|
||||||
<h1 className='text-dark fs-2qx fw-bolder text-center mb-7'>
|
<h1 className='text-white fs-2qx fw-bolder text-center mb-7'>
|
||||||
Fast, Efficient and Productive
|
Fast, Efficient and Productive
|
||||||
</h1>
|
</h1>
|
||||||
{/* end::Title */}
|
{/* end::Title */}
|
||||||
|
|
||||||
{/* begin::Text */}
|
{/* begin::Text */}
|
||||||
<div className='text-dark fs-base text-center'>
|
<div className='text-white fs-base text-center'>
|
||||||
In this kind of post,{' '}
|
In this kind of post,{' '}
|
||||||
<a href='#' className='opacity-75-hover text-warning fw-bold me-1'>
|
<a href='#' className='opacity-75-hover text-warning fw-bold me-1'>
|
||||||
the blogger
|
the blogger
|
||||||
</a>
|
</a>
|
||||||
introduces a person they’ve interviewed <br /> and provides some background information
|
introduces a person they’ve interviewed <br /> and provides some background information
|
||||||
about {' '}
|
about
|
||||||
<a href='#' className='opacity-75-hover text-warning fw-bold me-1'>
|
<a href='#' className='opacity-75-hover text-warning fw-bold me-1'>
|
||||||
the interviewee
|
the interviewee
|
||||||
</a>
|
</a>
|
||||||
@@ -149,7 +100,6 @@ const AuthLayout = () => {
|
|||||||
</div>
|
</div>
|
||||||
{/* end::Text */}
|
{/* end::Text */}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
{/* end::Content */}
|
{/* end::Content */}
|
||||||
</div>
|
</div>
|
||||||
{/* end::Aside */}
|
{/* end::Aside */}
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ const loginSchema = Yup.object().shape({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const initialValues = {
|
const initialValues = {
|
||||||
email: 'admin@demo.com',
|
email: '',
|
||||||
password: 'demo',
|
password: '',
|
||||||
}
|
}
|
||||||
|
//email: 'admin@demo.com',
|
||||||
/*
|
/*
|
||||||
Formik+YUP+Typescript:
|
Formik+YUP+Typescript:
|
||||||
https://jaredpalmer.com/formik/docs/tutorial#getfieldprops
|
https://jaredpalmer.com/formik/docs/tutorial#getfieldprops
|
||||||
@@ -39,18 +39,30 @@ 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)
|
||||||
|
// 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)
|
||||||
|
return
|
||||||
|
}
|
||||||
saveAuth(auth)
|
saveAuth(auth)
|
||||||
const {data: user} = await getUserByToken(auth.api_token)
|
setCurrentUser(auth.profile)
|
||||||
setCurrentUser(user)
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
saveAuth(undefined)
|
saveAuth(undefined)
|
||||||
setStatus('The login details are incorrect')
|
setStatus('The login details are incorrect')
|
||||||
setSubmitting(false)
|
setSubmitting(false)
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
|
} finally {
|
||||||
|
setTimeout(()=>{
|
||||||
|
setStatus('')
|
||||||
|
}, Number(process.env.REACT_APP_LOGIN_ERROR_TIMEOUT))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -63,6 +75,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'>
|
||||||
@@ -115,14 +132,6 @@ export function Login() {
|
|||||||
</div>
|
</div>
|
||||||
{/* end::Separator */}
|
{/* end::Separator */}
|
||||||
|
|
||||||
{formik.status ? (
|
|
||||||
<div className='mb-lg-15 alert alert-danger'>
|
|
||||||
<div className='alert-text font-weight-bold'>{formik.status}</div>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
null
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* begin::Form group */}
|
{/* begin::Form group */}
|
||||||
<div className='fv-row mb-8'>
|
<div className='fv-row mb-8'>
|
||||||
<label className='form-label fs-6 fw-bolder text-dark'>Email</label>
|
<label className='form-label fs-6 fw-bolder text-dark'>Email</label>
|
||||||
@@ -206,6 +215,16 @@ export function Login() {
|
|||||||
</div>
|
</div>
|
||||||
{/* end::Action */}
|
{/* end::Action */}
|
||||||
|
|
||||||
|
{/* error message */}
|
||||||
|
{formik.status ? (
|
||||||
|
<div className='mb-lg-15 alert alert-danger'>
|
||||||
|
<div className='alert-text font-weight-bold'>{formik.status}</div>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
null
|
||||||
|
)}
|
||||||
|
{/* end of error message */}
|
||||||
|
|
||||||
<div className='text-gray-500 text-center fw-semibold fs-6'>
|
<div className='text-gray-500 text-center fw-semibold fs-6'>
|
||||||
Not a Member yet?{' '}
|
Not a Member yet?{' '}
|
||||||
<Link to='/auth/registration' className='link-primary'>
|
<Link to='/auth/registration' className='link-primary'>
|
||||||
|
|||||||
@@ -86,7 +86,6 @@ export function Registration() {
|
|||||||
id='kt_login_signup_form'
|
id='kt_login_signup_form'
|
||||||
onSubmit={formik.handleSubmit}
|
onSubmit={formik.handleSubmit}
|
||||||
>
|
>
|
||||||
|
|
||||||
{/* begin::Login options */}
|
{/* begin::Login options */}
|
||||||
<div className='row g-3 mb-9'>
|
<div className='row g-3 mb-9'>
|
||||||
{/* begin::Col */}
|
{/* begin::Col */}
|
||||||
@@ -309,7 +308,7 @@ export function Registration() {
|
|||||||
<span>
|
<span>
|
||||||
I Accept the{' '}
|
I Accept the{' '}
|
||||||
<a
|
<a
|
||||||
href='https://keenthemes.com/metronic/?page=faq'
|
href='#'
|
||||||
target='_blank'
|
target='_blank'
|
||||||
className='ms-1 link-primary'
|
className='ms-1 link-primary'
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
Dispatch,
|
Dispatch,
|
||||||
SetStateAction,
|
SetStateAction,
|
||||||
} from 'react'
|
} from 'react'
|
||||||
|
import {useLocation} from 'react-router-dom'
|
||||||
import {LayoutSplashScreen} from '../../../../_res/layout/core'
|
import {LayoutSplashScreen} from '../../../../_res/layout/core'
|
||||||
import {AuthModel, UserModel} from './_models'
|
import {AuthModel, UserModel} from './_models'
|
||||||
import * as authHelper from './AuthHelpers'
|
import * as authHelper from './AuthHelpers'
|
||||||
@@ -61,17 +62,26 @@ const AuthProvider: FC<WithChildren> = ({children}) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const AuthInit: FC<WithChildren> = ({children}) => {
|
const AuthInit: FC<WithChildren> = ({children}) => {
|
||||||
|
const pathname = useLocation().pathname
|
||||||
const {auth, logout, setCurrentUser} = useAuth()
|
const {auth, logout, setCurrentUser} = useAuth()
|
||||||
const didRequest = useRef(false)
|
const didRequest = useRef(false)
|
||||||
const [showSplashScreen, setShowSplashScreen] = useState(true)
|
const [showSplashScreen, setShowSplashScreen] = useState(true)
|
||||||
// We should request user by authToken (IN OUR EXAMPLE IT'S API_TOKEN) before rendering the application
|
// We should request user by authToken (IN OUR EXAMPLE IT'S API_TOKEN) before rendering the application
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
// function to expire session after 5 mins
|
||||||
|
let logoutSession = setTimeout(()=>{ //expire session after 5 mins
|
||||||
|
logout()
|
||||||
|
}, Number(process.env.REACT_APP_SESSION_TIMEOUT))
|
||||||
|
|
||||||
const requestUser = async (apiToken: string) => {
|
const requestUser = async (apiToken: string) => {
|
||||||
try {
|
try {
|
||||||
if (!didRequest.current) {
|
if (!didRequest.current) {
|
||||||
const {data} = await getUserByToken(apiToken)
|
// const {data} = await getUserByToken(apiToken)
|
||||||
if (data) {
|
// if (data) {
|
||||||
setCurrentUser(data)
|
// setCurrentUser(data)
|
||||||
|
// }
|
||||||
|
if (localStorage.getItem('kt-auth-react-v')) {
|
||||||
|
setCurrentUser(auth.profile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -86,14 +96,18 @@ const AuthInit: FC<WithChildren> = ({children}) => {
|
|||||||
return () => (didRequest.current = true)
|
return () => (didRequest.current = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auth && auth.api_token) {
|
if (auth && auth.session_token) {
|
||||||
requestUser(auth.api_token)
|
requestUser(auth.session_token)
|
||||||
} else {
|
} else {
|
||||||
logout()
|
logout()
|
||||||
setShowSplashScreen(false)
|
setShowSplashScreen(false)
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
}, [])
|
|
||||||
|
return ()=>{ // clears session timeout side effect
|
||||||
|
clearInterval(logoutSession)
|
||||||
|
}
|
||||||
|
}, [pathname])
|
||||||
|
|
||||||
return showSplashScreen ? <LayoutSplashScreen /> : <>{children}</>
|
return showSplashScreen ? <LayoutSplashScreen /> : <>{children}</>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ export function setupAxios(axios: any) {
|
|||||||
axios.interceptors.request.use(
|
axios.interceptors.request.use(
|
||||||
(config: {headers: {Authorization: string}}) => {
|
(config: {headers: {Authorization: string}}) => {
|
||||||
const auth = getAuth()
|
const auth = getAuth()
|
||||||
if (auth && auth.api_token) {
|
if (auth && auth.session_token) {
|
||||||
config.headers.Authorization = `Bearer ${auth.api_token}`
|
config.headers.Authorization = `Bearer ${auth.session_token}`
|
||||||
}
|
}
|
||||||
|
|
||||||
return config
|
return config
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
export interface AuthModel {
|
export interface AuthModel {
|
||||||
api_token: string
|
session_token: string
|
||||||
refreshToken?: string
|
refreshToken?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ export const REQUEST_PASSWORD_URL = `${API_URL}/forgot_password`
|
|||||||
// Server should return AuthModel
|
// Server should return AuthModel
|
||||||
export function login(email: string, password: string) {
|
export function login(email: string, password: string) {
|
||||||
return axios.post<AuthModel>(LOGIN_URL, {
|
return axios.post<AuthModel>(LOGIN_URL, {
|
||||||
email,
|
username: email,
|
||||||
password,
|
password: password,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ export function requestPassword(email: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getUserByToken(token: string) {
|
export function getUserByToken(token: string) {
|
||||||
return axios.post<UserModel>(GET_USER_BY_ACCESSTOKEN_URL, {
|
return axios.get<UserModel>(GET_USER_BY_ACCESSTOKEN_URL, {
|
||||||
api_token: token,
|
session_token: token,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user