Processing the registration with a Route Handler
Now we will process the sent form data (email and password) and match the given email with the tenant’s domain, or else reject it. With a successful registration, we will send an activation link. To do this, let’s start by reading and validating the data.
Reading and validating the form data
To process the registration, we need a Route Handler at app/[tenant]/auth/register/route.js
. As our form sends POST
data, the function needs to be named POST
. Let’s add some Route Handler code to read the form data and the tenant, and output it as a JSON for us to check whether everything works as expected:
export async function POST(request, { params }) { const formData = await request.formData(); const name = formData.get("name"); const email = formData.get("email"); const password = formData.get("password"); const tenant = params...