-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathmagic.tsx
More file actions
18 lines (16 loc) · 766 Bytes
/
magic.tsx
File metadata and controls
18 lines (16 loc) · 766 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import type { LoaderFunction } from '@remix-run/node'
import { auth } from '~/services/auth.server'
import { getUserSession } from '~/services/session.server'
export const loader: LoaderFunction = async ({ request }) => {
const session = await getUserSession(request)
const redirectTo = (session.get('redirectTo') as string) || '/dashboard'
await auth.authenticate('email-link', request, {
// If the user was authenticated, we redirect them to their saved redirectTo
// or dashboard as fallback.
successRedirect: redirectTo,
// If something failed we take them back to the login page
// This redirect is optional, if not defined any error will be throw and
// the ErrorBoundary will be rendered.
failureRedirect: '/login',
})
}