0.1.6 • Published 10 years ago

meetup-auth-fe-middleware v0.1.6

Weekly downloads
4
License
ISC
Repository
github
Last release
10 years ago

Build Status Coverage Status js-standard-style

meetup-auth-fe-middleware

Redux middleware for Oauth2 connection on the client side. Tokens are stored in localStorage.

Installation

npm install --save meetup-auth-fe-middleware

Usage

import { applyMiddleware } from 'redux'
import authMiddleware from 'meetup-auth-fe-middleware'

applyMiddleware(
    authMiddleware({
      clientId: 'your-client-id', // required
      redirectUri: 'your-redirect-uri', //required
      authUrl: 'https://secure.dev.meetup.com/oauth2/authorize/' // required
    })
  )

Connecting

  1. dispatch this action:
import { INIT_AUTH } from 'meetup-auth-fe-middleware'

{
  type: INIT_AUTH
}

Getting the token

  1. dispatch this action:
import { CONFIGURE } from 'meetup-auth-fe-middleware'

{
  type: CONFIGURE
}
  1. This will call the next reducer with either:
{
  type: TOKEN_RETRIEVED,
  payload: {
    token // the retrieved token
  }
}

or:

{
  type: TOKEN_NOT_FOUND
}
  1. in your reducer:
import { TOKEN_RETRIEVED } from 'meetup-auth-fe-middleware'

// ...
case TOKEN_RETRIEVED:
  return { token: action.payload.token } // state === { token }
// ...

Disconnect

  1. Dispatch this action:
import { REMOVE_TOKEN } from 'meetup-auth-fe-middleware'

{
  type: REMOVE_TOKEN
}
  1. in your reducer:
import { REMOVE_TOKEN } from 'meetup-auth-fe-middleware'

// ...
case REMOVE_TOKEN:
  return { token: null } // state === { token: null }
// ...

Updating this package

  1. Make your changes
  2. npm version major|minor|patch. This will:
  3. Run unit tests
  4. Run eslint
  5. Update the version number in package.json
  6. Commit the update and also create a corresponding git tags
  7. Push the update and tag to GitHub
  8. npm publish to push the update to NPM
0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago