Compare commits

28 Commits

Author SHA1 Message Date
victorAnumudu accace3f60 added a function to expire session after 5 mins 2023-04-15 16:06:57 +01:00
ameye c49cc64196 Merge branch 'login_layout_revert' of FloatSystems/float-users into master 2023-04-15 09:54:58 +00:00
victorAnumudu 6a266ff772 anchor links added 2023-04-15 10:44:45 +01:00
victorAnumudu 4fcd3104df login layout reverted and login function cleaned up 2023-04-15 07:29:03 +01:00
victorAnumudu bfc956137f added right section 2023-04-15 06:24:59 +01:00
ameye b4ddd86bc2 Merge branch 'login_default_entry_removal' of FloatSystems/float-users into master 2023-04-14 21:19:15 +00:00
victorAnumudu f41a9961ae uncommented logout function 2023-04-14 22:12:40 +01:00
victorAnumudu 9376f96543 default login values removed 2023-04-14 21:55:18 +01:00
tokslaw 500c54d442 Merge branch 'login_user' of FloatSystems/float-users into master 2023-04-14 19:20:44 +00:00
tokslaw 85bd79a612 Merge branch 'login_centralized' of FloatSystems/float-users into master 2023-04-14 18:57:25 +00:00
victorAnumudu c17f95351f login user implemented 2023-04-14 19:49:59 +01:00
victorAnumudu 1be78e7484 centralized login and removed image 2023-04-14 15:14:31 +01:00
tokslaw 9103a812b5 Merge branch 'changed-loading-icon' of FloatSystems/float-users into master 2023-04-12 11:19:45 +00:00
victorAnumudu 7dc8503861 loading icon changed 2023-04-11 18:34:48 +01:00
tokslaw a819bcca1f Merge branch 'bg-color-cover' of FloatSystems/float-users into master 2023-04-11 17:18:47 +00:00
victorAnumudu 161bac928b removed image shadow 2023-04-11 18:04:12 +01:00
victorAnumudu 40834b9c38 made the bg color to cover all page 2023-04-11 15:37:37 +01:00
victorAnumudu 7a823fcf74 made the bg color to cover all page 2023-04-11 15:34:16 +01:00
DESKTOP-GBA0BK8\Admin faa4fdf8a6 demo pass changed 2023-04-08 14:48:15 -04:00
DESKTOP-GBA0BK8\Admin a33d405c8c Fix links 2023-04-08 10:41:39 -04:00
tokslaw 56570fbd33 Merge branch 'random_bg' of FloatSystems/float-users into master 2023-04-07 23:15:46 +00:00
victorAnumudu 2d657165bd added a fxn that changes bg color on page refresh 2023-04-07 19:29:04 +01:00
tokslaw 7daf939239 Merge branch 'logo_aligned' of FloatSystems/float-users into master 2023-04-05 19:15:31 +00:00
victorAnumudu 8355b291c9 aligned Logo Image 2023-04-05 19:38:59 +01:00
tokslaw 7a5becdaed Merge branch 'bg-revert' of FloatSystems/float-users into master 2023-04-05 12:52:23 +00:00
victorAnumudu 1fb997db0a text color changed to dark 2023-04-05 06:16:58 +01:00
victorAnumudu 69edd5cac0 bg reverted 2023-04-05 06:05:27 +01:00
tokslaw 11d55b1f10 Merge branch 'float_customization' of FloatSystems/float-users into master 2023-04-05 00:53:39 +00:00
12 changed files with 87 additions and 80 deletions
+2 -1
View File
@@ -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
@@ -18,3 +18,4 @@ 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_TERMS=https://www.float.sg/terms
REACT_APP_SITE_ABOUT_US=https://www.float.sg/about
REACT_APP_SESSION_TIMEOUT=300000
+1 -1
View File
@@ -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>
+4
View File
@@ -0,0 +1,4 @@
.auth-height {
min-height: 100vh;
}
+1
View File
@@ -13,3 +13,4 @@
@import "content";
@import "toolbar";
@import "page-title";
@import "auth";
+26 -40
View File
@@ -60,59 +60,45 @@ const AuthLayout = () => {
{/* begin::Aside */}
<div
className='position-relative d-flex flex-lg-row-fluid w-lg-50 order-1 order-lg-2'
// style={{backgroundImage: `url(${toAbsoluteUrl('/media/misc/auth-bg.png')})`}}
style={{backgroundImage: `url(${toAbsoluteUrl('/media/misc/auth-bg-new.svg')})`, backgroundRepeat: 'no-repeat', backgroundSize: 'cover', backgroundPosition: 'left top'}}
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')})`}}
>
{/* overlay div section */}
{/* <div className='position-absolute w-100 h-100 top-0 left-0' style={{backgroundColor: 'rgba(0, 0, 0, .4)', zIndex: '1'}}></div> */}
{/* begin::Content */}
<div className='position-relative d-flex flex-column flex-center py-15 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 */}
{/* <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
<img
className='mx-auto w-275px w-md-50 w-xl-500px mb-10 mb-lg-20'
src={toAbsoluteUrl('/media/misc/auth-screens.png')}
alt=''
/> */}
{/* <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'}}
/> */}
/>
{/* end::Image */}
<div className='w-100 w-md-75 rounded p-3 p-lg-5' style={{backgroundColor: 'rgba(0, 0, 0, .8)', boxShadow: '0px 0px 10px white'}}>
{/* begin::Title */}
<h1 className='text-white fs-2qx fw-bolder text-center mb-7 py-3'>
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 theyve 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> */}
<div className='text-white fs-base text-center py-3'>
<p>Improve quality of life for the world's population by <a href='#' className='opacity-75-hover text-warning fw-bold me-1'>building</a> the future global transportation platform.</p>
<p>Increasing accessibility and personal choices, <a href='#' className='opacity-75-hover text-warning fw-bold me-1'>while reducing</a> travel time traffic congestion, pollution, and loss to local GDP</p>
</div>
{/* end::Text */}
{/* 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 theyve 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>
{/* end::Content */}
</div>
@@ -50,12 +50,13 @@ export function ForgotPassword() {
id='kt_login_password_reset_form'
onSubmit={formik.handleSubmit}
>
<div className='text-center mb-10'>
{/* begin::Title */}
{/* <h1 className='text-dark fw-bolder mb-3'>Forgot Password ?</h1> */}
{/* 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' />
{/* end::Title */}
</div>
{/* begin::Heading */}
<div className='text-center mb-10'>
{/* begin::Link */}
<div className='text-gray-500 fw-semibold fs-6'>
Enter your email to reset your password.
+15 -10
View File
@@ -21,10 +21,10 @@ const loginSchema = Yup.object().shape({
})
const initialValues = {
email: 'admin@demo.com',
password: 'demo',
email: '',
password: '',
}
//email: 'admin@demo.com',
/*
Formik+YUP+Typescript:
https://jaredpalmer.com/formik/docs/tutorial#getfieldprops
@@ -39,12 +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)
// 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)
const {data: user} = await getUserByToken(auth.api_token)
setCurrentUser(user)
setCurrentUser(auth.profile)
console.log(auth) //remove later
} catch (error) {
console.error(error)
saveAuth(undefined)
@@ -125,11 +135,6 @@ export function Login() {
<div className='alert-text font-weight-bold'>{formik.status}</div>
</div>
) : (
// <div className='mb-10 bg-light-info p-8 rounded'>
// <div className='text-info'>
// Any text before login box - please configure
// </div>
// </div>
null
)}
@@ -88,15 +88,10 @@ export function Registration() {
>
{/* begin::Heading */}
<div className='text-center mb-11'>
{/* begin::Title */}
{/* <h1 className='text-dark fw-bolder mb-3'>Sign Up</h1> */}
{/* <h1 className='text-dark fw-bolder mb-3'>Sign In</h1> */}
<img alt='Float Mobility' src={toAbsoluteUrl('/media/logos/logo.png')} className='h-35px' />
{/* end::Title */}
{/* <div className='text-gray-500 fw-semibold fs-6'>Your Social Campaigns</div> */}
</div>
{/* end::Heading */}
{/* begin::Heading */}
{/* begin::Login options */}
<div className='row g-3 mb-9'>
{/* begin::Col */}
@@ -319,7 +314,7 @@ export function Registration() {
<span>
I Accept the{' '}
<a
href='https://keenthemes.com/metronic/?page=faq'
href='#'
target='_blank'
className='ms-1 link-primary'
>
+20 -6
View File
@@ -8,6 +8,7 @@ import {
Dispatch,
SetStateAction,
} from 'react'
import {useLocation} from 'react-router-dom'
import {LayoutSplashScreen} from '../../../../_res/layout/core'
import {AuthModel, UserModel} from './_models'
import * as authHelper from './AuthHelpers'
@@ -61,17 +62,26 @@ const AuthProvider: FC<WithChildren> = ({children}) => {
}
const AuthInit: FC<WithChildren> = ({children}) => {
const pathname = useLocation().pathname
const {auth, logout, setCurrentUser} = useAuth()
const didRequest = useRef(false)
const [showSplashScreen, setShowSplashScreen] = useState(true)
// We should request user by authToken (IN OUR EXAMPLE IT'S API_TOKEN) before rendering the application
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) => {
try {
if (!didRequest.current) {
const {data} = await getUserByToken(apiToken)
if (data) {
setCurrentUser(data)
// const {data} = await getUserByToken(apiToken)
// if (data) {
// setCurrentUser(data)
// }
if (localStorage.getItem('kt-auth-react-v')) {
setCurrentUser(auth.profile)
}
}
} catch (error) {
@@ -86,14 +96,18 @@ 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)
}
// eslint-disable-next-line
}, [])
return ()=>{ // clears session timeout side effect
clearInterval(logoutSession)
}
}, [pathname])
return showSplashScreen ? <LayoutSplashScreen /> : <>{children}</>
}
+2 -2
View File
@@ -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 -1
View File
@@ -1,5 +1,5 @@
export interface AuthModel {
api_token: string
session_token: string
refreshToken?: string
}
+4 -4
View File
@@ -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,
})
}