1
0
forked from noxious/client

npm run format

This commit is contained in:
2024-06-02 02:35:42 +02:00
parent 8329afe897
commit 86b80f8244
28 changed files with 572 additions and 562 deletions

View File

@ -1,32 +1,32 @@
import axios from 'axios';
import config from '@/config';
import { useSocketStore } from '@/stores/socket';
import axios from 'axios'
import config from '@/config'
import { useSocketStore } from '@/stores/socket'
import { useCookies } from '@vueuse/integrations/useCookies'
export async function register(username: string, password: string, socketStore = useSocketStore()) {
try {
const response = await axios.post(`${config.server_endpoint}/register`, { username, password });
const response = await axios.post(`${config.server_endpoint}/register`, { username, password })
if (response.status === 200) {
useCookies().set('token', response.data.token as string)
await socketStore.setupSocketConnection();
return true;
await socketStore.setupSocketConnection()
return true
}
} catch (error) {
console.error('Error registering user:', error);
return false;
console.error('Error registering user:', error)
return false
}
}
export async function login(username: string, password: string, socketStore = useSocketStore()) {
try {
const response = await axios.post(`${config.server_endpoint}/login`, { username, password });
const response = await axios.post(`${config.server_endpoint}/login`, { username, password })
if (response.status === 200) {
useCookies().set('token', response.data.token as string)
await socketStore.setupSocketConnection();
return true;
await socketStore.setupSocketConnection()
return true
}
} catch (error) {
console.error('Login failed:', error);
return false;
console.error('Login failed:', error)
return false
}
}
}