0.0.4 • Published 6 years ago

authoc v0.0.4

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

authoc is a Private Route solution for React apps that use React-Redux, and React Router.

Installation

npm install --save authoc

This module is only for projects that use React, Redux, React-Redux, and React-Router (4+)

Usage:

In your React Router config, simply pass the protected component(React Component), redirect route (String), and the auth field target in Redux state (Array).

import authoc from 'authoc';
import { Route } from 'react-router-dom';
import Protected from './components/Protected';

/*
example_Redux_State = {
    auth: {
       authenticated: false // any non-truthy value undefined, false, null ...
    },
    {...otherKeys}
};
// the target is state.auth.authenticated
*/

const protectedComponent = authoc(Protected, '/', ['auth', 'authenticated']);

<Route path="/secretpage" component={protectedComponent} />

TODO:

  1. Write tests
  2. Publish babel transpiled version
  3. Provide an option to pass a mock object rather than an array of keys for state target
0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago