Hi I have been working on the organisation flow and I have currently got it working by inviting a member through the Auth0 Dashboard and opening the email. It correctly shows the organisation sign up form, I complete the form, complete the 2FA step, it then shows me the authorise step for handling the scopes. After accepting that is when I hit the error. It’s just a black screen with the message:
Cannot read properties of undefined (reading 'returnTo')
As shown in the screenshot. It looks correct as a code is returned in the URL and I can confirm that the user is created and is now a member of the organisation, which is great. I can ignore the message and login as the new user and its displays correctly as a member of the organisation.
As this feels very close it would be great to complete the loop so that after a successful accept and sign up of the invitation, the user is redirected to the home page.
For more context here is my […auth].js
import { handleAuth, handleLogin } from '@auth0/nextjs-auth0';
function getSingleOrUndefined(
item: string | string[] | undefined
): string | undefined {
if (!item) {
return undefined;
}
const newItem = Array.isArray(item) ? item[0] : item;
return !newItem || newItem === 'undefined' ? undefined : newItem;
}
export default handleAuth({
login: (req, res, opts) => {
return handleLogin(req, res, {
...opts,
authorizationParams: {
...opts?.authorizationParams,
invitation: getSingleOrUndefined(req.query.invitation),
organization: getSingleOrUndefined(req.query.organization),
},
});
},
});
Here is an example of my authorise url:
https://dev-charitybi.eu.auth0.com/oauth/authorize?
audience=https://dev-charitybi.eu.auth0.com/api/v2&
response_type=code&
client_id=sKoEAqwKXmCncRyUWXvHdjo5IWpS8JsU&
redirect_uri=https://www.dev.charity.bi/api/auth/callback&
invitation=Tcq0mXAmzIQOfVyF9KfbTVC3dPlqcANL&
organization=org_uVyLDsgxSTkDc4nj&
organization_name=org-name
In case I am missing anything? I have also attempted to join ?returnTo=https://dev.charity.bi to the callback url but that returned the same error.
Any advice is appreciated, thanks