This commit is contained in:
nquidox 2025-09-09 23:19:17 +03:00
commit 72c796c429
21 changed files with 4956 additions and 0 deletions

41
src/stores/authStore.js Normal file
View file

@ -0,0 +1,41 @@
import { defineStore } from 'pinia';
import { computed, ref } from 'vue';
import apiClient from '@/services/apiClient';
export const useAuthStore = defineStore('auth', () => {
// state
const accessToken = ref(null)
const user = ref(null)
// getters
const isAuthenticated = computed(() => !!accessToken.value)
// actions
const login = async (email, password) => {
try {
const response = await apiClient.post(
"/user/login",
{ email, password }
)
const { access_token } = response.data
accessToken.value = access_token
console.log('Email', email)
console.log('Password', password)
} catch (error) {
console.log(error)
}
}
const logout = () => {
console.log('logout placeholder')
}
return {
accessToken,
user,
isAuthenticated,
login,
logout
}
})