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

Function onSignUpWithMagicLink

apps/web/ui/Auth/common.ts:134–175  ·  view source on GitHub ↗
({
  setError,
  setLoading,
  callbackUrl,
  state,
  sso,
}: {
  setError: (arg: string) => void;
  setLoading: (arg: boolean) => void;
  callbackUrl?: string;
  state?: string;
  sso?: string;
})

Source from the content-addressed store, hash-verified

132}
133
134export function onSignUpWithMagicLink({
135 setError,
136 setLoading,
137 callbackUrl,
138 state,
139 sso,
140}: {
141 setError: (arg: string) => void;
142 setLoading: (arg: boolean) => void;
143 callbackUrl?: string;
144 state?: string;
145 sso?: string;
146}) {
147 return async (event: any) => {
148 event.preventDefault();
149 const form = event.target;
150 const email = form.email.value;
151 const displayName = form.displayName.value;
152
153 if (!email) {
154 setError('Email is required');
155 return;
156 }
157
158 try {
159 setLoading(true);
160 const csrfToken = form?.csrfToken?.value || (await getCsrfToken());
161
162 await signInWithMagicLink(email, csrfToken, {
163 callbackUrl,
164 displayName,
165 state,
166 sso,
167 });
168 window.location.href = '/verify-request';
169 } catch (error: any) {
170 setError(error);
171 } finally {
172 setLoading(false);
173 }
174 };
175}
176
177export function onSignUpWithCredsSubmit({
178 setError,

Callers 1

onSubmitFunction · 0.90

Calls 2

getCsrfTokenFunction · 0.90
signInWithMagicLinkFunction · 0.85

Tested by

no test coverage detected