mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-07 19:10:12 +08:00
feat: add login & signup flow
This commit is contained in:
1 parent
f1510df13e
commit
f5c465ab69
3 files changed
+166
-22
No files matched your search
@@ -40,6 +40,24 @@ export const login = async (username, password) => {
|
||||
}
|
||||
}
|
||||
|
||||
export const register = async (username, email, password) => {
|
||||
try {
|
||||
const res = await api.post('/auth/register', {
|
||||
username,
|
||||
password,
|
||||
email,
|
||||
})
|
||||
const { token } = res.data
|
||||
myToken.value = token
|
||||
return true
|
||||
} catch (err) {
|
||||
if (err.response?.status === 409) {
|
||||
return false
|
||||
}
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
||||
export const logout = () => {
|
||||
myToken.value = null
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user