Giter Club home page Giter Club logo

react-boilerplate-auth's Introduction

React Boilerplate Auth

React Boilerplate extended swith login/register flow built with React & Redux Saga. react-boilerplate-auth.herokuapp.com

Authentication

Authentication happens in app/auth/index.js, using fakeRequest.js and fakeServer.js. fakeRequest is a fake XMLHttpRequest wrapper. fakeServer responds to the fake HTTP requests and pretends to be a real server, storing the current users in local storage with the passwords encrypted using bcrypt.

Demo

react-boilerplate-auth.herokuapp.com

Username: test
Password: password

Available routes:

  • /home (only accessible when logged in)
  • /login
  • /register

Quick Start

  1. Clone this repo using git clone [email protected]:andreasasprou/react-boilerplate-auth.git
  2. Run npm run setup to install dependencies and clean the git repo.
  3. At this point you can run npm start to see the example app at http://localhost:3000.

Documentation about the extensive features of React Boilerplate and general use of this boilerplate can be found here.

I highly reccommend you read this before attempting to create a project using this boilerplate.

All global reducers, sagas and actions responsible for authentication are defined under /App. Examples of logging in, logging out and registering new users are described in the containers LoginPage, HomePage and RegisterPage respectively.

Creating Secure Routes

To create a secure route (one which cannot be accessed without logging in), ensure that when creating a new route in app/routes.js, you set the onEnter property to (nextState, replace) => checkAuth(store, nextState, replace).

E.g.

...
}, {
  path: 'home',
  name: 'homePage',
  onEnter: (nextState, replace) => checkAuth(store, nextState, replace),
  getComponent(location, cb) {
    import
    ('containers/HomePage')
      .then(loadModule(cb))
      .catch(errorLoading);
  },
}, {
...

Credits

react-boilerplate-auth's People

Contributors

andreasasprou avatar

Watchers

iamsweelai avatar

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.