Compare commits

...

7 Commits

Author SHA1 Message Date
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
8 changed files with 30 additions and 75 deletions
+1 -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
+2 -2
View File
@@ -1,4 +1,4 @@
.auth-gray {
background-color: $gray-200;
.auth-height {
min-height: 100vh;
}
+3 -56
View File
@@ -54,9 +54,9 @@ const AuthLayout = () => {
}, [])
return (
<div className='d-flex flex-column flex-lg-row flex-column-fluid overflow-auto' style={{backgroundImage: `${bgColor.backgroundImage}`}}>
<div className='auth-height d-flex flex-column flex-lg-row flex-column-fluid' 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'>
<div className='d-flex flex-column flex-lg-row-fluid w-lg-50 p-10 order-2 order-lg-1'>
{/* begin::Form */}
<div className='d-flex flex-center flex-column flex-lg-row-fluid'>
<div className='text-center mb-11'>
@@ -64,7 +64,7 @@ const AuthLayout = () => {
<img alt='Float Mobility' src={toAbsoluteUrl('/media/logos/logo.png')} className='h-35px' />
</div>
{/* begin::Wrapper */}
<div className='auth-gray w-lg-500px p-10 shadow-lg rounded-sm'>
<div className='bg-white w-lg-500px p-10 shadow-lg rounded'>
<Outlet />
</div>
{/* end::Wrapper */}
@@ -99,59 +99,6 @@ const AuthLayout = () => {
</div>
{/* end::Body */}
{/* begin::Aside */}
<div
className='position-relative d-flex flex-lg-row-fluid w-lg-50 p-10 order-1 order-lg-2'
>
{/* 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'>
<img alt='Float Mobility' src={toAbsoluteUrl('/media/logos/logo.png')} className='h-35px' />
</Link> */}
{/* end::Logo */}
{/* <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 */}
<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 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>
</div>
{/* end::Content */}
</div>
{/* end::Aside */}
</div>
)
}
+9 -4
View File
@@ -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,8 +23,8 @@ const loginSchema = Yup.object().shape({
})
const initialValues = {
email: 'demo@float.sg',
password: '****',
email: '',
password: '',
}
//email: 'admin@demo.com',
/*
@@ -32,6 +34,7 @@ const initialValues = {
*/
export function Login() {
const navigate = useNavigate()
const [loading, setLoading] = useState(false)
const {saveAuth, setCurrentUser} = useAuth()
@@ -43,8 +46,10 @@ export function Login() {
try {
const {data: auth} = await login(values.email, values.password)
saveAuth(auth)
const {data: user} = await getUserByToken(auth.api_token)
setCurrentUser(user)
// const {data: user} = await getUserByToken(auth.session_token)
// setCurrentUser(user)
setCurrentUser(auth.profile)
navigate('/dashboard')
} catch (error) {
console.error(error)
saveAuth(undefined)
+8 -5
View File
@@ -69,9 +69,12 @@ const AuthInit: FC<WithChildren> = ({children}) => {
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,8 +89,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)
+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,
})
}