fix: db errors are now handled correctly
This commit is contained in:
parent
9568470610
commit
ef752d9add
2 changed files with 18 additions and 8 deletions
|
|
@ -41,7 +41,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleDBErrors(e: ClientResponseError) {
|
function handleDBErrors(e: ClientResponseError) {
|
||||||
if (e.data.lenght > 0) {
|
if (Object.keys(e.data).length > 0) {
|
||||||
const element = Object.keys(e.data.data)[0];
|
const element = Object.keys(e.data.data)[0];
|
||||||
formErrors[element] = true;
|
formErrors[element] = true;
|
||||||
const dbError = e.data.data[element];
|
const dbError = e.data.data[element];
|
||||||
|
|
@ -100,7 +100,7 @@
|
||||||
<div class="grid gap-2">
|
<div class="grid gap-2">
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<Label for="password">Password</Label>
|
<Label for="password">Password</Label>
|
||||||
<a class="ml-auto inline-block text-sm underline-offset-4 hover:underline">
|
<a href="/auth/resetPassword" class="ml-auto inline-block text-sm underline-offset-4 hover:underline cursor-pointer">
|
||||||
Forgot your password?
|
Forgot your password?
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -53,12 +53,22 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleDBErrors(e: ClientResponseError) {
|
function handleDBErrors(e: ClientResponseError) {
|
||||||
const element = Object.keys(e.data.data)[0];
|
console.error(e)
|
||||||
formErrors[element] = true;
|
if (Object.keys(e.data).length > 0) {
|
||||||
const dbError = e.data.data[element];
|
const element = Object.keys(e.data.data)[0];
|
||||||
if (dbError.code === 'validation_not_unique') {
|
formErrors[element] = true;
|
||||||
error = `This ${element} is already used by someone. Maybe try logging in if it's you.`;
|
const dbError = e.data.data[element];
|
||||||
} else error = dbError.message;
|
|
||||||
|
if (dbError.code === 'validation_not_unique') {
|
||||||
|
error = `This ${element} is already used by someone. Maybe try logging in if it's you.`;
|
||||||
|
} else error = dbError.message;
|
||||||
|
} else {
|
||||||
|
formErrors.email = true;
|
||||||
|
formErrors.name = true;
|
||||||
|
formErrors.password = true;
|
||||||
|
formErrors.passwordConfirm = true;
|
||||||
|
error = e.message;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function register() {
|
async function register() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue