Support international emails in login (#21454)

Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch>
This commit is contained in:
Daniel Biegler
2024-02-21 00:55:13 +01:00
committed by GitHub
parent 630a75b489
commit d793ce888b
2 changed files with 11 additions and 3 deletions

View File

@@ -0,0 +1,5 @@
---
'@directus/app': patch
---
Fixed an issue that prevented logging in when emails contained unicode characters

View File

@@ -56,7 +56,10 @@ const errorFormatted = computed(() => {
});
async function onSubmit() {
if (email.value === null || password.value === null) {
// Simple RegEx, not for validation, but to prevent unnecessary login requests when the value is clearly invalid
const emailRegex = /^\S+@\S+$/;
if (email.value === null || !emailRegex.test(email.value) || password.value === null) {
error.value = 'INVALID_PAYLOAD';
return;
}
@@ -77,7 +80,7 @@ async function onSubmit() {
const redirectQuery = router.currentRoute.value.query.redirect as string;
let lastPage: string | undefined;
let lastPage: string | null = null;
if (userStore.currentUser && 'last_page' in userStore.currentUser) {
lastPage = userStore.currentUser.last_page;
@@ -97,7 +100,7 @@ async function onSubmit() {
</script>
<template>
<form @submit.prevent="onSubmit">
<form novalidate @submit.prevent="onSubmit">
<v-input v-model="email" autofocus autocomplete="username" type="email" :placeholder="t('email')" />
<v-input v-model="password" type="password" autocomplete="current-password" :placeholder="t('password')" />