fix(frontend): show confirmation notice when registration requires email verification

After a successful registration the frontend auto-logs-in. With email
confirmation enabled that login fails with 412 (code 1012), which
surfaced as a raw "Request failed with status code 412" error in the
register form even though the account was created fine. Treat that case
as a success and tell the user to check their inbox instead.
This commit is contained in:
kolaente
2026-08-18 11:30:03 +02:00
parent 3833b34d37
commit 595f4c3edc
3 changed files with 18 additions and 3 deletions
+2 -1
View File
@@ -104,7 +104,8 @@
"remember": "Stay logged in",
"registrationDisabled": "Registration is disabled.",
"passwordResetTokenMissing": "Password reset token is missing.",
"registrationFailed": "An error occurred during registration. Please check your input and try again."
"registrationFailed": "An error occurred during registration. Please check your input and try again.",
"registrationConfirmEmail": "Your account was created successfully! Please check your inbox and click the link in the confirmation email before logging in."
},
"settings": {
"bots": {
+2 -2
View File
@@ -238,12 +238,12 @@ export const useAuthStore = defineStore('auth', () => {
...credentials,
language,
})
return login(credentials)
return await login(credentials)
} catch (e) {
if (e.response?.data?.code === 2002 && e.response?.data?.invalid_fields[0]?.startsWith('language:')) {
return register(credentials, 'en')
}
if (e.response?.data?.message) {
throw e.response.data
}
+14
View File
@@ -7,6 +7,13 @@
>
{{ errorMessage }}
</Message>
<Message
v-if="confirmEmailMessage !== ''"
variant="success"
class="mbe-4"
>
{{ confirmEmailMessage }}
</Message>
<form
id="registerform"
@submit.prevent="submit"
@@ -136,6 +143,7 @@ const credentials = reactive({
const isLoading = computed(() => authStore.isLoading)
const errorMessage = ref('')
const confirmEmailMessage = ref('')
const validatePasswordInitially = ref(false)
const serverValidationErrors = ref<Partial<Record<string, string>>>({})
@@ -233,6 +241,12 @@ async function submit() {
await authStore.register(toRaw(credentials))
redirectIfSaved()
} catch (e: unknown) {
// 1012 = email not confirmed: registration itself succeeded
if (e instanceof Object && 'code' in e && e.code === 1012) {
confirmEmailMessage.value = t('user.auth.registrationConfirmEmail')
return
}
// Parse field-specific validation errors
if (isApiValidationError(e)) {
const fieldErrors = parseValidationErrors(e)