Skip to content

Commit

Permalink
Show better message for improperly formatted emails (directus#6168)
Browse files Browse the repository at this point in the history
  • Loading branch information
rijkvanzanten authored Jun 9, 2021
1 parent fb908ef commit c2c57ef
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/src/routes/login/components/login-form/login-form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default defineComponent({
const loggingIn = ref(false);
const email = ref<string | null>(null);
const password = ref<string | null>(null);
const error = ref<RequestError | null>(null);
const error = ref<RequestError | string | null>(null);
const otp = ref<string | null>(null);
const requiresTFA = ref(false);
const userStore = useUserStore();
Expand All @@ -57,6 +57,11 @@ export default defineComponent({
});
const errorFormatted = computed(() => {
// Show "Wrong username or password" for wrongly formatted emails as well
if (error.value === 'INVALID_PAYLOAD') {
return translateAPIError('INVALID_CREDENTIALS');
}
if (error.value) {
return translateAPIError(error.value);
}
Expand Down Expand Up @@ -89,7 +94,7 @@ export default defineComponent({
if (err.response?.data?.errors?.[0]?.extensions?.code === 'INVALID_OTP' && requiresTFA.value === false) {
requiresTFA.value = true;
} else {
error.value = err;
error.value = err.response?.data?.errors?.[0]?.extensions?.code || err;
}
} finally {
loggingIn.value = false;
Expand Down

0 comments on commit c2c57ef

Please sign in to comment.