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

AppLoadContext type seems to not match how it is designed to work

Open samjohnduke opened this issue 2 years ago • 0 comments

I am trying to work out how to get some arbitrary data into the form strategy as a means of creating an history of sign-in but the type on the context object seems strange.

export async function action({ context, request }: ActionArgs) {
  return await authenticator.authenticate("form", request, {
    successRedirect: "/",
    failureRedirect: "/login",
    context, // optional
  });
};

on this one, you are passing the remix context - which is all good.

but then you also override it with formData on the next one.

export async function action({ context, request }: ActionArgs) {
  let formData = await request.formData();
  return await authenticator.authenticate("form", request, {
    // use formData here
    successRedirect: formData.get("redirectTo"),
    failureRedirect: "/login",
    context: { formData }, // pass pre-read formData here
  });
};

but it should still be typed as AppLoadContext, It seems like this type might want to be generic or somehow user customizable? is that a fair assumption?

(ps happy to submit a pr if worthwhile)

samjohnduke avatar Nov 08 '22 06:11 samjohnduke