remix-auth-form icon indicating copy to clipboard operation
remix-auth-form copied to clipboard

Example is incorrect

Open fzn0x opened this issue 8 months ago • 0 comments

Hi @sergiodxa Thanks for making this library battle tested in production, but I have some issue with successRedirect, after I figured out, the problem is we need to throw the Response.

export async function action({
  request,
}: ActionFunctionArgs): ActionReturnType {
  try {
    return await authenticator.authenticate("sk-user-pass", request, {
      successRedirect: "/admin/dashboard",
      throwOnError: true,
    });
  } catch (err) {
    if (err instanceof Response) {
      throw err;
    }

    return json({
      error: (err as Error).message,
    });
  }
}

I think we need to improve the repository example.

fzn0x avatar Jun 08 '24 01:06 fzn0x