MCPcopy Create free account
hub / github.com/Linen-dev/linen.dev / signInWithMagicLink

Function signInWithMagicLink

apps/web/ui/Auth/common.ts:32–60  ·  view source on GitHub ↗
(
  email: string,
  csrfToken: string,
  options: {
    callbackUrl?: string;
    displayName?: string;
    state?: string;
    sso?: string;
  } = {}
)

Source from the content-addressed store, hash-verified

30}
31
32async 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
62export function onSignInSubmit({
63 setError,

Callers 2

onSignInSubmitFunction · 0.85
onSignUpWithMagicLinkFunction · 0.85

Calls 2

getMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected