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

Function signInWithCreds

apps/web/ui/Auth/common.ts:6–30  ·  view source on GitHub ↗
(
  email: string,
  password: string,
  csrfToken: string,
  sso?: string
)

Source from the content-addressed store, hash-verified

4import { localStorage } from '@linen/utilities/storage';
5
6async function signInWithCreds(
7 email: string,
8 password: string,
9 csrfToken: string,
10 sso?: string
11) {
12 const thread = localStorage.get('nouser.thread');
13 const message = localStorage.get('nouser.message');
14 localStorage.remove('nouser.thread');
15 localStorage.remove('nouser.message');
16 return await fetch(`/api/auth/callback/credentials?${qs({ sso })}`, {
17 method: 'POST',
18 headers: { 'Content-Type': 'application/json' },
19 body: JSON.stringify({
20 username: String(email).toLowerCase(),
21 password,
22 thread,
23 message,
24 csrfToken,
25 }),
26 }).then((r) => {
27 if (r.ok) return r.json();
28 else throw r.json();
29 });
30}
31
32async function signInWithMagicLink(
33 email: string,

Callers 2

onSignInSubmitFunction · 0.85
onSignUpWithCredsSubmitFunction · 0.85

Calls 3

qsFunction · 0.90
getMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected