register method
This commit is contained in:
parent
0498e7ed4b
commit
bb91ac72df
1 changed files with 12 additions and 0 deletions
|
|
@ -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,
|
||||
}
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue