feature/#215-dexie-caching-implementation

This commit is contained in:
2024-10-21 02:08:27 +02:00
parent 279b9bc7a3
commit df19c1094c
16 changed files with 248 additions and 130 deletions

View File

@ -1,9 +1,8 @@
import axios from 'axios'
import config from '@/config'
import { useGameStore } from '@/stores/gameStore'
import { useCookies } from '@vueuse/integrations/useCookies'
export async function register(username: string, password: string, gameStore = useGameStore()) {
export async function register(username: string, password: string) {
try {
const response = await axios.post(`${config.server_endpoint}/register`, { username, password })
useCookies().set('token', response.data.token as string)
@ -13,13 +12,13 @@ export async function register(username: string, password: string, gameStore = u
}
}
export async function login(username: string, password: string, gameStore = useGameStore()) {
export async function login(username: string, password: string) {
try {
const response = await axios.post(`${config.server_endpoint}/login`, { username, password })
useCookies().set('token', response.data.token as string, {
// for whole domain
// @TODO : #190
domain: window.location.hostname.split('.').slice(-2).join('.')
// domain: window.location.hostname.split('.').slice(-2).join('.')
})
return { success: true, token: response.data.token }
} catch (error: any) {