Interface WithAuthenticationRequiredOptions

Options for the withAuthenticationRequired Higher Order Component

interface WithAuthenticationRequiredOptions {
    context?: Context<Auth0ContextInterface<User>>;
    loginOptions?: RedirectLoginOptions<AppState>;
    onBeforeAuthentication?: (() => Promise<void>);
    onRedirecting?: (() => Element);
    returnTo?: string | (() => string);
}

Properties

context?: Context<Auth0ContextInterface<User>>

The context to be used when calling useAuth0, this should only be provided if you are using multiple Auth0Providers within your application and you wish to tie a specific component to a Auth0Provider other than the Auth0Provider associated with the default Auth0Context.

withAuthenticationRequired(Profile, {
loginOptions: {
appState: {
customProp: 'foo'
}
}
})

Pass additional login options, like extra appState to the login page. This will be merged with the returnTo option used by the onRedirectCallback handler.

onBeforeAuthentication?: (() => Promise<void>)

Type declaration

    • (): Promise<void>
    • withAuthenticationRequired(Profile, {
      onBeforeAuthentication: () => { analyticsLibrary.track('login_triggered'); }
      })

      Allows executing logic before the user is redirected to the login page.

      Returns Promise<void>

onRedirecting?: (() => Element)

Type declaration

    • (): Element
    • withAuthenticationRequired(Profile, {
      onRedirecting: () => <div>Redirecting you to the login...</div>
      })

      Render a message to show that the user is being redirected to the login.

      Returns Element

returnTo?: string | (() => string)
withAuthenticationRequired(Profile, {
returnTo: '/profile'
})

or

withAuthenticationRequired(Profile, {
returnTo: () => window.location.hash.substr(1)
})

Add a path for the onRedirectCallback handler to return the user to after login.

Type declaration

    • (): string
    • Returns string