Hi,
I want to use an “invite code” to allow users to signup to my application as long as they have an invite code.
I am using @auth0/nextjs-auth0 package, and in my [...auth0].ts
file I’m overriding the handleAuth
function like so:
export default handleAuth({
callback: async (req: NextApiRequest, res: NextApiResponse) => {
try {
await handleCallback(req, res, { afterCallback });
} catch (error: any) {
res.status(error.status || 500).end();
}
},
login: async (req, res) => {
try {
const cookies = parse(req.headers.cookie ?? "");
const { inviteCode } = req.query;
await handleLogin(req, res, {
returnTo: req.cookies.returnTo
? req.cookies.returnTo
: process.env.AUTH0_BASE_URL,
authorizationParams: {
screen_hint: "signup",
response_type: "code",
scope: `openid profile email invite:${req.cookies.inviteCode}`,
inviteCode: inviteCode,
},
});
} catch (error: any) {
res.status(error.status || 500).end();
}
},
});
I have a problem with handleLogin
because I’m expecting to see the inviteCode
param in my Action/Hook, but that information never actually gets over to Auth0 Actions or Hooks.
I have a workaround by adding the inviteCode to the scope
property, which I know I shouldn’t be using for that purpose, but that’s the only property that I can mutate, and I can send the invite code.
Am I doing something wrong, or is there something wrong with the package? or is this not the appropriate flow to use?
Thanks