feat: native email input validation on login modal

This commit is contained in:
liyasthomas
2021-10-16 00:00:33 +05:30
parent c1ec5dc60d
commit 3e3b88b8c2
2 changed files with 12 additions and 14 deletions

View File

@@ -34,6 +34,7 @@
]" ]"
:disabled="disabled" :disabled="disabled"
:tabindex="loading ? '-1' : '0'" :tabindex="loading ? '-1' : '0'"
:type="type"
> >
<span <span
v-if="!loading" v-if="!loading"
@@ -143,6 +144,10 @@ export default defineComponent({
type: Array, type: Array,
default: () => [], default: () => [],
}, },
type: {
type: String,
default: "button",
},
}, },
}) })
</script> </script>

View File

@@ -26,7 +26,11 @@
@click.native="mode = 'email'" @click.native="mode = 'email'"
/> />
</div> </div>
<div v-if="mode === 'email'" class="flex flex-col space-y-2"> <form
v-if="mode === 'email'"
class="flex flex-col space-y-2"
@submit.prevent="signInWithEmail"
>
<div class="flex flex-col"> <div class="flex flex-col">
<input <input
id="email" id="email"
@@ -40,7 +44,6 @@
required required
spellcheck="false" spellcheck="false"
autofocus autofocus
@keyup.enter="signInWithEmail"
/> />
<label for="email"> <label for="email">
{{ $t("auth.email") }} {{ $t("auth.email") }}
@@ -48,18 +51,10 @@
</div> </div>
<ButtonPrimary <ButtonPrimary
:loading="signingInWithEmail" :loading="signingInWithEmail"
:disabled=" type="submit"
form.email.length !== 0
? emailRegex.test(form.email)
? false
: true
: true
"
type="button"
:label="`${$t('auth.send_magic_link')}`" :label="`${$t('auth.send_magic_link')}`"
@click.native="signInWithEmail"
/> />
</div> </form>
<div v-if="mode === 'email-sent'" class="flex flex-col px-4"> <div v-if="mode === 'email-sent'" class="flex flex-col px-4">
<div class="flex flex-col max-w-md justify-center items-center"> <div class="flex flex-col max-w-md justify-center items-center">
<SmartIcon class="h-6 text-accent w-6" name="inbox" /> <SmartIcon class="h-6 text-accent w-6" name="inbox" />
@@ -150,8 +145,6 @@ export default defineComponent({
signingInWithGoogle: false, signingInWithGoogle: false,
signingInWithGitHub: false, signingInWithGitHub: false,
signingInWithEmail: false, signingInWithEmail: false,
emailRegex:
/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/,
mode: "sign-in", mode: "sign-in",
} }
}, },