remix-auth-email-link
Advanced tools
Comparing version 1.5.0 to 1.5.1
{ | ||
"name": "remix-auth-email-link", | ||
"version": "1.5.0", | ||
"version": "1.5.1", | ||
"main": "./build/index.js", | ||
@@ -5,0 +5,0 @@ "types": "./build/index.d.ts", |
@@ -121,13 +121,9 @@ # Email Link Strategy - Remix Auth | ||
// app/routes/login.tsx | ||
import { | ||
Form, | ||
LoaderFunction, | ||
ActionFunction, | ||
json, | ||
useLoaderData, | ||
} from 'remix' | ||
import { ActionArgs, LoaderArgs } from '@remix-run/node' | ||
import { json } from '@remix-run/node' | ||
import { Form, useLoaderData } from '@remix-run/react' | ||
import { auth } from '~/services/auth.server' | ||
import { sessionStorage } from '~/services/session.server' | ||
export let loader: LoaderFunction = async ({ request }) => { | ||
export let loader = async ({ request }: LoaderArgs) => { | ||
await auth.isAuthenticated(request, { successRedirect: '/me' }) | ||
@@ -144,3 +140,3 @@ let session = await sessionStorage.getSession(request.headers.get('Cookie')) | ||
export let action: ActionFunction = async ({ request }) => { | ||
export let action = async ({ request }: ActionArgs) => { | ||
// The success redirect is required in this action, this is where the user is | ||
@@ -159,4 +155,3 @@ // going to be redirected after the magic link is sent, note that here the | ||
export default function Login() { | ||
let { magicLinkSent, magicLinkEmail } = | ||
useLoaderData<{ magicLinkSent: boolean; magicLinkEmail?: string }>() | ||
let { magicLinkSent, magicLinkEmail } = useLoaderData<typeof loader>() | ||
@@ -187,7 +182,8 @@ return ( | ||
// app/routes/magic.tsx | ||
import { LoaderFunction, ActionFunction, json } from 'remix' | ||
import { LoaderArgs } from '@remix-run/node' | ||
import { json } from '@remix-run/node' | ||
import { auth } from '~/services/auth.server' | ||
import { sessionStorage } from '~/services/session.server' | ||
export let loader: LoaderFunction = async ({ request }) => { | ||
export let loader = async ({ request }: LoaderArgs) => { | ||
await auth.authenticate('email-link', request, { | ||
@@ -209,6 +205,7 @@ // If the user was authenticated, we redirect them to their profile page | ||
// app/routes/me.tsx | ||
import { LoaderFunction, json } from 'remix' | ||
import { LoaderArgs } from '@remix-run/node' | ||
import { json } from '@remix-run/node' | ||
import { auth } from '~/services/auth.server' | ||
export let loader: LoaderFunction = async ({ request }) => { | ||
export let loader = async ({ request }: LoaderArgs) => { | ||
// If the user is here, it's already authenticated, if not redirect them to | ||
@@ -221,3 +218,3 @@ // the login page. | ||
export default function Me() { | ||
let { user } = useLoaderData<{ user: User }>() | ||
let { user } = useLoaderData<typeof loader>() | ||
return ( | ||
@@ -224,0 +221,0 @@ <div> |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30470
353