-
I am using the Remix Email Strategy, and I am trying to get it to authenticate (send a magic link) without the need to redirect upon success. On digging in, I think this requirement is in the remix-auth package (?). Is there a way to no redirect? I am using a dropdown login, and I don't want the change the page when a magic link has been sent. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Hey @684efs3, successRedirect is not required. You can see an example here. Calling |
Beta Was this translation helpful? Give feedback.
-
This is my code for login.tsx // Libraries
import { json } from "@remix-run/node";
import { auth } from "~/services/auth.server";
import { sessionStorage } from "~/services/session.server";
export let loader = async ({ request }) => {
await auth.isAuthenticated(request, { successRedirect: "/profile" });
let session = await sessionStorage.getSession(request.headers.get("Cookie"));
return json({
magicLinkSent: session.has("auth:magiclink"),
magicLinkEmail: session.get("auth:email"),
});
};
export let action = async ({ request }) => {
await auth.authenticate("email-link", request, {
// successRedirect: "/",
});
}; If I remove
Is this built into Remix Auth, or is this something that Remix Auth Email Strategy built in? Their docs say: export let action = async ({ request }: ActionArgs) => {
// The success redirect is required in this action, this is where the user is
// going to be redirected after the magic link is sent, note that here the
// user is not yet authenticated, so you can't send it to a private page.
await auth.authenticate('email-link', request, {
successRedirect: '/login',
// If this is not set, any error will be throw and the ErrorBoundary will be
// rendered.
failureRedirect: '/login',
})
} |
Beta Was this translation helpful? Give feedback.
Hey @684efs3, successRedirect is not required. You can see an example here. Calling
authenticate
will simply return the user (or whatever your strategy function returns).