refactor: simplify register flow

This commit is contained in:
Lin, Hung-Shin committed 2023-09-15 15:50:36 +08:00
1 parent 5dd56308ce
commit a6d02f2616
3 files changed
+32 -36

No files matched your search

+8 -15
View File
@@ -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 = () => {