Admin platform, with users, transactions, games and admin creation
This commit is contained in:
@@ -4,7 +4,7 @@ import { useAPIStore } from './api'
|
||||
|
||||
export const useAuthStore = defineStore('auth', () => {
|
||||
|
||||
const DEFAULT_TIMEOUT = 5 * 60 * 1000
|
||||
const DEFAULT_TIMEOUT = 30 * 60 * 1000
|
||||
const REMEMBER_ME_TIMEOUT = 365 * 24 * 60 * 60 * 1000
|
||||
|
||||
const currentUser = ref(undefined)
|
||||
@@ -20,6 +20,10 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
return currentUser.value?.id
|
||||
})
|
||||
|
||||
const isAdmin = computed(() => {
|
||||
return currentUser.value?.type === 'A'
|
||||
})
|
||||
|
||||
const isTokenAlmostExpired = () => {
|
||||
if (!tokenExpiry.value) return false;
|
||||
return Date.now() > (tokenExpiry.value - 60 * 1000);
|
||||
@@ -112,10 +116,16 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
return true
|
||||
}
|
||||
|
||||
const updateCurrentUserCoins = (coins) => {
|
||||
if (!currentUser.value) return;
|
||||
currentUser.value.coins_balance = coins
|
||||
}
|
||||
|
||||
return {
|
||||
currentUser,
|
||||
isLoggedIn,
|
||||
currentUserID,
|
||||
isAdmin,
|
||||
token,
|
||||
rememberMe,
|
||||
getToken,
|
||||
@@ -124,5 +134,6 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
resetTokenExpiry,
|
||||
isTokenAlmostExpired,
|
||||
restoreSession,
|
||||
updateCurrentUserCoins,
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user