GithubHelp home page GithubHelp logo

react-redux-auth0's Introduction

Use Auth0 with React + Redux

import { AuthComponent, AuthMiddlewares, AuthReducer } from 'react-redux-auth0'

When starting your app, include the following environment variables:

AUTH0_CLIENTID=client-id-string AUTH0_DOMAIN=domain npm your-start-command

Include Auth0 from CDN in your template (believe me, you don't want to build it):

<script src="//cdn.auth0.com/js/lock/10.11/lock.min.js"></script>

Usage with Webpack

Make sure you have this webpack plugin so that webpack will compile in proper environment variables:

  new webpack.DefinePlugin({
    'process.env.NODE_ENV': JSON.stringify(env),
    'process.env.AUTH0_CLIENTID': JSON.stringify(AUTH0_CLIENTID),
    'process.env.AUTH0_DOMAIN': JSON.stringify(AUTH0_DOMAIN)
  })

...here is an example of reading those env variables in webpack config:

const env = process.env.NODE_ENV;
const AUTH0_CLIENTID = process.env.AUTH0_CLIENTID;
const AUTH0_DOMAIN = process.env.AUTH0_DOMAIN;

AuthComponent

Can be used to render either a 'Sigup' or 'Login' button:


<AuthComponent login />

<AuthComponent signup />

...or will render both:

<AuthComponent onAuthenticated={callback} />

The component will automatically return a Logout button when the user is authenticated.

Options

auth0: auth0 lock customization options detailed here https://auth0.com/docs/libraries/lock/v10/customization onAuthenticated (token, profile): A callback to receive when authentication has completed.

react-redux-auth0's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-redux-auth0's Issues

Error when loading

I have the environment variables loaded using dotenv. I can verify that they're loading. Are there any steps missing from the README?

auth0 mount error Error: domain required as second parameter.(โ€ฆ)

Unable to import AuthMiddleware

import { AuthMiddleware } from 'react-redux-auth0'
let middlewares = applyMiddleware(routerMiddleware, thunk, AuthMiddleware)

I am getting the following error on the browser
bundle.js:30963 Uncaught TypeError: middleware is not a function

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.