(
email: string,
csrfToken: string,
options: {
callbackUrl?: string;
displayName?: string;
state?: string;
sso?: string;
} = {}
)
| 30 | } |
| 31 | |
| 32 | async function signInWithMagicLink( |
| 33 | email: string, |
| 34 | csrfToken: string, |
| 35 | options: { |
| 36 | callbackUrl?: string; |
| 37 | displayName?: string; |
| 38 | state?: string; |
| 39 | sso?: string; |
| 40 | } = {} |
| 41 | ) { |
| 42 | const thread = localStorage.get('nouser.thread'); |
| 43 | const message = localStorage.get('nouser.message'); |
| 44 | localStorage.remove('nouser.thread'); |
| 45 | localStorage.remove('nouser.message'); |
| 46 | return await fetch(`/api/auth/magic-link`, { |
| 47 | method: 'POST', |
| 48 | headers: { 'Content-Type': 'application/json' }, |
| 49 | body: JSON.stringify({ |
| 50 | destination: String(email).toLowerCase(), |
| 51 | csrfToken, |
| 52 | thread, |
| 53 | message, |
| 54 | ...options, |
| 55 | }), |
| 56 | }).then((r) => { |
| 57 | if (r.ok) return r.json(); |
| 58 | else throw r.json(); |
| 59 | }); |
| 60 | } |
| 61 | |
| 62 | export function onSignInSubmit({ |
| 63 | setError, |
no test coverage detected