Initial project

This commit is contained in:
liangping
2021-07-21 22:07:38 +08:00
commit ae30de057d
465 changed files with 52080 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
import useJwt from '@core/auth/jwt/useJwt'
import axios from '@axios'
const { jwt } = useJwt(axios, {})
export default jwt
+27
View File
@@ -0,0 +1,27 @@
import useJwt from '@/auth/jwt/useJwt'
/**
* Return if user is logged in
* This is completely up to you and how you want to store the token in your frontend application
* e.g. If you are using cookies to store the application please update this function
*/
// eslint-disable-next-line arrow-body-style
export const isUserLoggedIn = () => {
return localStorage.getItem('userData') && localStorage.getItem(useJwt.jwtConfig.storageTokenKeyName)
}
export const getUserData = () => JSON.parse(localStorage.getItem('userData'))
/**
* This function is used for demo purpose route navigation
* In real app you won't need this function because your app will navigate to same route for each users regardless of ability
* Please note role field is just for showing purpose it's not used by anything in frontend
* We are checking role just for ease
* NOTE: If you have different pages to navigate based on user ability then this function can be useful. However, you need to update it.
* @param {String} userRole Role of user
*/
export const getHomeRouteForLoggedInUser = userRole => {
if (userRole === 'admin') return '/'
if (userRole === 'client') return { name: 'access-control' }
return { name: 'auth-login' }
}