Skip to content

Commit e5044f1

Browse files
committed
feat(auth): implement passwordless magic link signin
1 parent 075cf2b commit e5044f1

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

lib/features/auth/auth-service.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,30 @@ export async function signIn(
199199
}
200200
}
201201

202+
// Sign in or sign up with magic link (Passwordless)
203+
export async function signInWithEmail(
204+
email: string,
205+
): Promise<{ success: boolean; error?: string }> {
206+
try {
207+
const supabase = createClient()
208+
209+
const { error: signInError } = await supabase.auth.signInWithOtp({
210+
email,
211+
options: {
212+
emailRedirectTo: `${window.location.origin}/auth/callback`,
213+
}
214+
})
215+
216+
if (signInError) {
217+
return { success: false, error: signInError.message }
218+
}
219+
220+
return { success: true }
221+
} catch (error: any) {
222+
return { success: false, error: error.message || 'Magic link failed' }
223+
}
224+
}
225+
202226
// Sign out user
203227
export async function signOut(): Promise<void> {
204228
try {

0 commit comments

Comments
 (0)