# auth-jwt-reducer

> Redux Auth reducer for JWT enabled client side applications.

Latest version **1.0.4** (published 2017-02-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install auth-jwt-reducer
pnpm add auth-jwt-reducer
yarn add auth-jwt-reducer
bun add auth-jwt-reducer
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2017-02-25 |
| First published | 2017-02-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Nelson Perez |
| Maintainers | elnelsonperez |
| Keywords | auth, redux, jwt, reducer |

## Links

- npm: https://www.npmjs.com/package/auth-jwt-reducer
- Repository: https://github.com/elnelsonperez/auth-jwt-reducer
- Homepage: https://github.com/elnelsonperez/auth-jwt-reducer#readme
- Issues: https://github.com/elnelsonperez/auth-jwt-reducer/issues
- npm.io page: https://npm.io/package/auth-jwt-reducer

## Dependencies (3)

- [react](https://npm.io/package/react.md) ^15.4.2
- [react-redux](https://npm.io/package/react-redux.md) ^5.0.3
- [react-router-redux](https://npm.io/package/react-router-redux.md) ^4.0.8

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads

## Recent versions

- 1.0.4 (latest) — 2017-02-25
- 1.0.2 — 2017-02-25
- 1.0.1 — 2017-02-25
- 1.0.0 — 2017-02-22

## README

Auth-jwt-reducer
=========

Some mashed together auth modules i use in my react projects.
This is meant to work along side redux, react-redux-router

## Installation

  `npm install auth-jwt-reducer`

##Conditions

The reducer expects you to have a reducer with react-router-redux, like this
        {
          auth: YourAuthReducer,
          routing: routerReducer
        }

And these are the AuthWrapper Proptypes
       
        AuthWrapper.propTypes = {
                  pathSelector: React.PropTypes.func,
                  authSelector: React.PropTypes.func,
                  validatingPage: React.PropTypes.element,
                  setTokenAction: React.PropTypes.func,
                  tokenName: React.PropTypes.string,
                  loginUrl: React.PropTypes.string
                }
                
        AuthWrapper.defaultProps = {
          tokenName: 'jwttoken',
          loginUrl: '/login'
        }

The AuthWrapper goes as a high level route in the route that renders its children depending on if the user is
logged in. When logged in, if trying to access from another tab, the AuthWrapper checks for a previously set token
with the specified key so it can automatically login.

## Default State
      {
       //Logged User Data
        user: null
       //Logged user JWT token
        token: null
       //Attempting login
        attempting: false
        error: null
        validatingExistingToken: false
      }

## Actions handled by reducer
      AUTH_LOGIN | Expects nothing.
      AUTH_LOGIN_SUCCESS | Expects action.payload.user and action.payload.token.
      AUTH_LOGIN_ERROR | Expects action.payload to be error.
      AUTH_SET_TOKEN_SUCCESS | Expects action.payload.user and action.payload.token.
      AUTH_SET_TOKEN_ERROR | Expects action.payload to be error.
      AUTH_LOGOUT | Expects nothing.
## Usage

    import { reducer } from 'auth-jwt-reducer'

Then just use the reducer in Redux.

---
_Source: https://npm.io/package/auth-jwt-reducer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
