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
@@ -57,25 +57,9 @@ async function check() {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!isRegister.value) {
|
||||
check()
|
||||
return
|
||||
}
|
||||
// register
|
||||
function handleRegister() {
|
||||
console.log('register', username.value, email.value, password.value)
|
||||
api
|
||||
.get('/auth/check', {
|
||||
params: { username: username.value },
|
||||
})
|
||||
.then(() => {
|
||||
// Username is available, now check if the email already exists
|
||||
return api.get('/auth/check', { params: { email: email.value } })
|
||||
})
|
||||
.then(() => {
|
||||
// Both username and email are available, proceed with registration
|
||||
return register(username.value, email.value, password.value)
|
||||
})
|
||||
register(username.value, email.value, password.value)
|
||||
.then((isSuccess) => {
|
||||
if (isSuccess) {
|
||||
success()
|
||||
@@ -102,6 +86,15 @@ async function handleSubmit() {
|
||||
})
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!isRegister.value) {
|
||||
check()
|
||||
return
|
||||
}
|
||||
// register
|
||||
handleRegister()
|
||||
}
|
||||
|
||||
const clearError = () => {
|
||||
errorMessage.value = ''
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user