Global

Methods

withAuth() → {function}

A simple wrapper to any component that will only display the component if the user is in an authenticated state. It will look for props injected into the component to determine whether to display either:

  • A Failure Component (when the authenticatedSelector returns false)
  • An Authenticating/Pending Component (when authenticatingSelector returns true and authenticatedSelector also returns false)
  • Your actual Component (when the authenticatedSelector returns true) If the optional components are not provided null will be rendered/returned when in those states.
Parameters:
Name Type Description
args.authenticatedSelector function | String

A prop name OR a selector function that will find the prop injected into the component that identifies whether the user is authenticated or not (defaults to look for a prop named isAuthenticated)

args.authenticatingSelector function | String

A prop name OR a selector function that will find the prop injected into the component that identifies whether the user authentication is in-progress or not (defaults to look for a prop named isAuthenticating)

args.AuthenticatingComponent function

An optional component that would be displaying while authentication is in-progress (defaults to an empty Component that returns null)

args.FailureComponent function

An optional component that would be diplayed when authentication fails (defaults to a Component Component that returns null)

args.wrapperDisplayName String

An optional display name to give to the wrapper component (defaults to just 'AuthWrapper')

Returns:
function -

A function that is ready to receive a Component to decorate

withAuthAndRedirect() → {function}

A simple wrapper to any component that will only display the component if the user is in an authenticated state. Unlike the withAuth higher-order component, this one will default to a given route or relative URL when authentication fails. It will look for props injected into the component to determine whether to display either:

  • A Failure Component (when the authenticatedSelector returns false, but will default to render a redirect component)
  • An Authenticating/Pending Component (when authenticatingSelector returns true and authenticatedSelector also returns false)
  • Your actual Component (when the authenticatedSelector returns true)
Parameters:
Name Type Description
args.authenticatedSelector function | String

A prop name OR a selector function that will find the prop injected into the component that identifies whether the user is authenticated or not (defaults to look for a prop named isAuthenticated)

args.authenticatingSelector function | String

A prop name OR a selector function that will find the prop injected into the component that identifies whether the user authentication is in-progress or not (defaults to look for a prop named isAuthenticating)

args.redirectPath function | String

A prop name OR a selector function that will find the prop injected into the component that identifies the route or relative URL to send the user to when authentication fails

args.AuthenticatingComponent function

An optional component that would be displaying while authentication is in-progress (defaults to an empty Component that returns null)

args.allowRedirectBack Boolean

Whether or not to redirect back to the original location after authentication completes successfully

args.FailureComponent function

An optional component that would be diplayed when authentication fails (defaults to a Component Component that returns null, but redirects to whatever it finds on the redirectPath)

args.wrapperDisplayName String

An optional display name to give to the wrapper component (defaults to just 'AuthWrapper')

args.redirectQueryParamName String

An optional prop name to identify the route/relative-URL from the component's injected props

Returns:
function -

A function that is ready to receive a Component to decorate

withAuthFromContext() → {function}

A simple wrapper to any component that will only display the component if the user is in an authenticated state. Unlike the withAuth higher-order component, this one is expecting a Context Consumer to be provided, and it will use the props provided to the consumer to apply the authenticated/authenticating selectors. It will look for props injected into the component to determine whether to display either:

  • A Failure Component (when the authenticatedSelector returns false)
  • An Authenticating/Pending Component (when authenticatingSelector returns true and authenticatedSelector also returns false)
  • Your actual Component (when the authenticatedSelector returns true) If the optional components are not provided null will be rendered/returned when in those states.
Parameters:
Name Type Description
args.authenticatedSelector function | String

A prop name OR a selector function that will find the prop injected into the component that identifies whether the user is authenticated or not (defaults to look for a prop named isAuthenticated)

args.authenticatingSelector function | String

A prop name OR a selector function that will find the prop injected into the component that identifies whether the user authentication is in-progress or not (defaults to look for a prop named isAuthenticating)

args.ContextConsumer function

An instance of a .Consumer from the context object that React.createContext() returns

args.AuthenticatingComponent function

An optional component that would be displaying while authentication is in-progress (defaults to an empty Component that returns null)

args.FailureComponent function

An optional component that would be diplayed when authentication fails (defaults to a Component Component that returns null)

args.wrapperDisplayName String

An optional display name to give to the wrapper component (defaults to just 'AuthWrapper')

Returns:
function -

A function that is ready to receive a Component to decorate

withAuthFromContextAndRedirect() → {function}

A simple wrapper to any component that will only display the component if the user is in an authenticated state. Unlike the withAuth higher-order component, this one will default to a given route or relative URL when authentication fails. Additionally, it is driven by a context consumer component (one of the props returned in the output of React.createContext()). It will look for props injected into the component to determine whether to display either:

  • A Failure Component (when the authenticatedSelector returns false, but will default to render a redirect component)
  • An Authenticating/Pending Component (when authenticatingSelector returns true and authenticatedSelector also returns false)
  • Your actual Component (when the authenticatedSelector returns true)
Parameters:
Name Type Description
args.authenticatedSelector function | String

A prop name OR a selector function that will find the prop injected into the component that identifies whether the user is authenticated or not (defaults to look for a prop named isAuthenticated)

args.authenticatingSelector function | String

A prop name OR a selector function that will find the prop injected into the component that identifies whether the user authentication is in-progress or not (defaults to look for a prop named isAuthenticating)

args.redirectPath function | String

A prop name OR a selector function that will find the prop injected into the component that identifies the route or relative URL to send the user to when authentication fails

args.AuthenticatingComponent function

An optional component that would be displaying while authentication is in-progress (defaults to an empty Component that returns null)

args.ContextConsumer function

An instance of a .Consumer from the context object that React.createContext() returns

args.allowRedirectBack Boolean

Whether or not to redirect back to the original location after authentication completes successfully

args.FailureComponent function

An optional component that would be diplayed when authentication fails (defaults to a Component Component that returns null, but redirects to whatever it finds on the redirectPath)

args.wrapperDisplayName String

An optional display name to give to the wrapper component (defaults to just 'AuthWrapper')

args.redirectQueryParamName String

An optional prop name to identify the route/relative-URL from the component's injected props

Returns:
function -

A function that is ready to receive a Component to decorate