Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs for logout seem stale #550

Closed
6 tasks done
nipunn1313 opened this issue Jul 12, 2023 · 2 comments
Closed
6 tasks done

Docs for logout seem stale #550

nipunn1313 opened this issue Jul 12, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@nipunn1313
Copy link

Checklist

Description

  /**
   * ```js
   * auth0.logout({ returnTo: window.location.origin });
   * ```
   *
   * Clears the application session and performs a redirect to `/v2/logout`, using
   * the parameters provided as arguments, to clear the Auth0 session.
   * If the `logoutParams.federated` option is specified, it also clears the Identity Provider session.
   * [Read more about how Logout works at Auth0](https://auth0.com/docs/logout).
   */
  logout: (options?: LogoutOptions) => Promise<void>;

Notably it recommends

auth0.logout({ returnTo: window.location.origin });

but actually it needs to be

        logout({
          async openUrl(url) {
            await Browser.open({ url })
          },
        })

or simply

logout()

Reproduction

Here's a component which reproes

function LogoutButton() {
  const { logout } = useAuth0()
  return (
    <button className="btn btn-primary" onClick={() => logout({ returnTo: window.location.origin })}>
      Log out
    </button>
  )
}

Additional context

No response

auth0-react version

2.0.1

React version

18.2.0

Which browsers have you tested in?

Chrome

@nipunn1313 nipunn1313 added the bug Something isn't working label Jul 12, 2023
@frederikprijck
Copy link
Member

frederikprijck commented Jul 12, 2023

Thanks for reporting this. The code sample for logout in the jsdocs is incorrect and for v2 it should be:

auth0.logout({
  logoutParams: {
    returnTo: '...'
  }
})

You can use returnTo to tell Auth0 where it should redirect back to, after logging out.

I opened a PR to fix that code sample, but for the rest, the docs seem to be still accurate.

As you are using Browser.open(), are you using Capacitor's browser? If so, we have specific guidance for integrating the SDK with Capacitor's browser here : https://auth0.com/docs/quickstart/native/ionic-react

@nipunn1313
Copy link
Author

nope! I filed the task before I got it fully working (I was just fiddling autocomplete).
Ended up being exactly what you described!

auth0.logout({
  logoutParams: {
    returnTo: '...'
  }
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants