( email: string, password: string, csrfToken: string, sso?: string )
| 4 | import { localStorage } from '@linen/utilities/storage'; |
| 5 | |
| 6 | async 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 | |
| 32 | async function signInWithMagicLink( |
| 33 | email: string, |
no test coverage detected