Using email-link auth strategy to send subsequent user invites #11
-
Looking to use Example: a project management app which can invite multiple users to collaborate on a project. Ideal solution: Using Current action function: export const action: ActionFunction = async ({ request }) => {
const raw = await request.formData()
const fields = Object.fromEntries(raw)
if (fields._action === 'AddUser') {
const email = fields.email.toString()
const role = fields.role.toString()
const newUser = await createNewInvitedUser(email, user.account_id, role)
if (!newUser) {
return json({ success: false, error: { message: "Internal server error while creating user." } }, { status: 500 })
}
// here is where I'd like to trigger the magic link to send the new user
await authenticator.authenticate('email-link', request, {
successRedirect: '/valuers'
})
}
//...
} Just looking for ideas on how to best implement this, as running into various errors thanks to little http experience and low understanding of how remix-auth works. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
This already looks correct. The only thing I would change is: in the first line I would do |
Beta Was this translation helpful? Give feedback.
This already looks correct. The only thing I would change is: in the first line I would do
await request.clone().formData()