Skip to content

v4.4.x | Empty onCallback context for InvalidStateError, returnTo missing. #2053

Open
@jesseflikweerteo

Description

@jesseflikweerteo

Checklist

Description

Whenever we route someone to e.g. /auth/login?prompt=none&returnTo=/somepath and the auth fails with an AuthorizationError we get a context with the returnTo url (e.g. /somepath). That's nice, since we can use that to present someone with a 'try logging in again' button that links to /auth/login?returnTo=/somepath, to make sure the user still ends up where they originally wanted to go.

However, when that same auth request fails with an InvalidStateError, the context is an empty object, and the returnTo seems to be missing. In this case the user is just lost in our webapp, since we're supposed to be relying on the returnTo URL's. Is this missing context on some callback errors a bug or a feature?

Image
Image

Reproduction

Route user that's not logged in to /auth/login?prompt=none&returnTo=/somepath to make sure the user gets an error, then based on chance (we still don't know when the user gets either an InvalidStateError or an AuthorizationError:
a) In case of an InvalidStateError, notice that you get an empty context, so without a returnTo url.
b) In case of an AuthorizationError, notice that you get the context you expected, so with a returnTo url.

The same happens for auth0.startInteractiveLogin({returnTo: '/somepath', ...}), regardless of how you pass the returnTo to an auth request: in case of an InvalidStateError the context seems to be missing.

Additional context

No response

nextjs-auth0 version

v4.4.0

Next.js version

v14.2.28

Node.js version

v20.10.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions