mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 03:20:12 +08:00
feat: add error handling for choose username
This commit is contained in:
1 parent
20225093c6
commit
cbe7adc3f8
4 files changed
+81
-48
No files matched your search
@@ -5,8 +5,7 @@ import { passwordPolicy } from '@linux-odyssey/constants'
|
||||
import AuthForm from '../components/AuthForm.vue'
|
||||
import Background from '../components/DynamicBackground.vue'
|
||||
|
||||
import api from '../utils/api'
|
||||
import { register } from '../utils/auth'
|
||||
import { checkUsername, register } from '../utils/auth'
|
||||
import {
|
||||
UnauthorizedError,
|
||||
TooManyRequestsError,
|
||||
@@ -52,13 +51,7 @@ async function check({ username, email, password, error }) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
const res = await api.get('/auth/check-username', {
|
||||
params: { username },
|
||||
})
|
||||
const { available } = res.data
|
||||
if (!available) {
|
||||
error(`Username already exists.`)
|
||||
}
|
||||
await checkUsername(username)
|
||||
} catch (err) {
|
||||
if (err.response?.status === 400) {
|
||||
error('Invalid username.')
|
||||
|
||||
Reference in new issue
Block a user