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
authenticatedSelectorreturnsfalse) - An Authenticating/Pending Component (when
authenticatingSelectorreturnstrueandauthenticatedSelectoralso returnsfalse) - Your actual Component (when the
authenticatedSelectorreturnstrue) If the optional components are not providednullwill be rendered/returned when in those states.
Parameters:
Name Type Description args.authenticatedSelectorfunction | 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.authenticatingSelectorfunction | 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.AuthenticatingComponentfunction An optional component that would be displaying while authentication is in-progress (defaults to an empty Component that returns
null)args.FailureComponentfunction An optional component that would be diplayed when authentication fails (defaults to a Component Component that returns
null)args.wrapperDisplayNameString 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
- A Failure Component (when the
-
withAuthAndRedirect() → {function}
-
A simple wrapper to any component that will only display the component if the user is in an authenticated state. Unlike the
withAuthhigher-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
authenticatedSelectorreturnsfalse, but will default to render a redirect component) - An Authenticating/Pending Component (when
authenticatingSelectorreturnstrueandauthenticatedSelectoralso returnsfalse) - Your actual Component (when the
authenticatedSelectorreturnstrue)
Parameters:
Name Type Description args.authenticatedSelectorfunction | 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.authenticatingSelectorfunction | 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.redirectPathfunction | 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.AuthenticatingComponentfunction An optional component that would be displaying while authentication is in-progress (defaults to an empty Component that returns
null)args.allowRedirectBackBoolean Whether or not to redirect back to the original location after authentication completes successfully
args.FailureComponentfunction 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 theredirectPath)args.wrapperDisplayNameString An optional display name to give to the wrapper component (defaults to just 'AuthWrapper')
args.redirectQueryParamNameString 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
- A Failure Component (when the
-
withAuthFromContext() → {function}
-
A simple wrapper to any component that will only display the component if the user is in an authenticated state. Unlike the
withAuthhigher-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
authenticatedSelectorreturnsfalse) - An Authenticating/Pending Component (when
authenticatingSelectorreturnstrueandauthenticatedSelectoralso returnsfalse) - Your actual Component (when the
authenticatedSelectorreturnstrue) If the optional components are not providednullwill be rendered/returned when in those states.
Parameters:
Name Type Description args.authenticatedSelectorfunction | 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.authenticatingSelectorfunction | 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.ContextConsumerfunction An instance of a
.Consumerfrom the context object that React.createContext() returnsargs.AuthenticatingComponentfunction An optional component that would be displaying while authentication is in-progress (defaults to an empty Component that returns
null)args.FailureComponentfunction An optional component that would be diplayed when authentication fails (defaults to a Component Component that returns
null)args.wrapperDisplayNameString 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
- A Failure Component (when the
-
withAuthFromContextAndRedirect() → {function}
-
A simple wrapper to any component that will only display the component if the user is in an authenticated state. Unlike the
withAuthhigher-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
authenticatedSelectorreturnsfalse, but will default to render a redirect component) - An Authenticating/Pending Component (when
authenticatingSelectorreturnstrueandauthenticatedSelectoralso returnsfalse) - Your actual Component (when the
authenticatedSelectorreturnstrue)
Parameters:
Name Type Description args.authenticatedSelectorfunction | 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.authenticatingSelectorfunction | 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.redirectPathfunction | 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.AuthenticatingComponentfunction An optional component that would be displaying while authentication is in-progress (defaults to an empty Component that returns
null)args.ContextConsumerfunction An instance of a
.Consumerfrom the context object that React.createContext() returnsargs.allowRedirectBackBoolean Whether or not to redirect back to the original location after authentication completes successfully
args.FailureComponentfunction 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 theredirectPath)args.wrapperDisplayNameString An optional display name to give to the wrapper component (defaults to just 'AuthWrapper')
args.redirectQueryParamNameString 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
- A Failure Component (when the