Skip to content

POSTing to form strategy from a different route action? #160

Answered by sergiodxa
tconroy asked this question in Q&A
Discussion options

You must be logged in to vote

Once createUser returns a new user you can manually store it in the session yourself. You only need to be sure the key of the session is the same used by Remix Auth, you can do that by using authenticator.sessionKey.

// routes/join
export const action = async ({ request }) => {
  const result = await serverSideSignupValidator.validate(await request.formData());
  if (result.error) return validationError(result.error);

  let user = await createUser(result.email, result.password);

  let session = await getSession(request.headers.get("cookie"));
  session.set(authenticator.sessionKey, user);

  return redirect("/somewhere", {
    headers: { "Set-Cookie": await commitSession(session) }
  });
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sergiodxa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants