Skip to content
This repository was archived by the owner on Oct 23, 2025. It is now read-only.

Commit 2b25291

Browse files
fix: check for blank email address on magic links (#221)
* check for blank email address on magic links * Add changeset file to bump the package version --------- Co-authored-by: Andrew Smith <a.smith@silentworks.co.uk>
1 parent 5607ea4 commit 2b25291

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@supabase/auth-ui-shared': patch
3+
'@supabase/auth-ui-react': patch
4+
---
5+
6+
Fix check for blank email address on magic links

packages/react/src/components/Auth/interfaces/MagicLink.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ function MagicLink({
3636
setError('')
3737
setMessage('')
3838
setLoading(true)
39+
40+
if (email.length === 0) {
41+
setError(i18n?.magic_link?.empty_email_address as string)
42+
setLoading(false)
43+
return
44+
}
3945
const { error } = await supabaseClient.auth.signInWithOtp({
4046
email,
4147
options: { emailRedirectTo: redirectTo },
@@ -60,9 +66,10 @@ function MagicLink({
6066
type="email"
6167
autoFocus
6268
placeholder={labels?.email_input_placeholder}
63-
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
69+
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
70+
if (setError) setError('')
6471
setEmail(e.target.value)
65-
}
72+
}}
6673
appearance={appearance}
6774
/>
6875
</div>

packages/shared/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ export type I18nVariables = {
137137
loading_button_label?: string
138138
link_text?: string
139139
confirmation_text?: string
140+
empty_email_address?: string
140141
}
141142
forgotten_password?: {
142143
email_label?: string

0 commit comments

Comments
 (0)