mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
refactor: simplify register flow
This commit is contained in:
1 parent
5dd56308ce
commit
a6d02f2616
3 files changed
+32
-36
No files matched your search
+8
-15
@@ -41,21 +41,14 @@ 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
|
||||
}
|
||||
const res = await api.post('/auth/register', {
|
||||
username,
|
||||
password,
|
||||
email,
|
||||
})
|
||||
const { token } = res.data
|
||||
myToken.value = token
|
||||
return true
|
||||
}
|
||||
|
||||
export const logout = () => {
|
||||
|
||||
Reference in new issue
Block a user