New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

auth0-react-redux

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

auth0-react-redux

React components for authenticating with Auth0

  • 0.1.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Auth0 Redux

React components for authenticating with auth0

Installation

npm install auth0-react-redux

Usage

  1. Ensure the authReducer has been added to your rootReducer
import { AUTH_REDUCER_KEY, authReducer } from 'auth0-react-redux'

const rootReducer = combineReducers({
    [AUTH_REDUCER_KEY]: authReducer,
    // other reducers
})

const store = createStore(rootReducer)
  1. Wrap your app with <AuthProvider>, and ensure there is a valid callback route. This is the route that auth0 will redirect to after a successful login, and the path must be saved in the allowed callbacks section inside your auth0 client.
import { Provider } from 'react-redux'
import { AuthProvider, AuthCallback } from 'auth0-react-redux'

const authConfig = {
    domain: 'foobar.auth0.com',
    clientID: 'foobar',
    callbackURL: '/',
}

ReactDOM.render(
    <Provider>
        <AuthProvider authOptions={authConfig}>
            <Route exact path="/callback" component={AuthCallback} />
        </AuthProvider>
    </Provider>
)

HOC for authenticated routes

Two Higher Order Components have been provided to ensure your users are logged in/out.

type withAuthentication: (WrappedComponent: any, redirectUrl: string | null = null) => JSX.Element
type withoutAuthentication: (WrappedComponent: any, redirectUrl: string | null = null) => JSX.Element

These can be used as follows:

import { withoutAuthentication, withoutAuthentication } from 'auth0-react-redux'

const ProfilePage = withAuthentication(() => (
    <div>You are logged in</div>
))

const LandingPage = withoutAuthentication(() => (
    <div>You are logged out</div>
))

If the user is not logged in they will be redirected to auth0.

FAQs

Package last updated on 30 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc