From bb91ac72dfe97b2d9ef5d463cd0ecd13c22bcf19 Mon Sep 17 00:00:00 2001 From: nquidox Date: Fri, 12 Sep 2025 23:49:10 +0300 Subject: [PATCH] register method --- src/stores/authStore.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/stores/authStore.js b/src/stores/authStore.js index 71017f2..ded1db0 100644 --- a/src/stores/authStore.js +++ b/src/stores/authStore.js @@ -52,6 +52,17 @@ export const useAuthStore = defineStore('auth', () => { router.push({ name: 'startPage'}) } + const register = async (email, password) => { + try { + const response = await apiClient.post('/user', { email, password }) + if (response.data.code === 200) { + router.push({ name: 'login' }) + } + } catch (error) { + console.error('Register error:', error) + } + } + return { accessToken, user, @@ -60,5 +71,6 @@ export const useAuthStore = defineStore('auth', () => { login, logout, forceLogout, + register, } })