2.0.0 • Published 7 years ago

provide-authentication v2.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

provide-authentication

build status npm version npm downloads

Provider factory for authenticating to some resource.

Table of contents

  1. Installation
  2. Usage
  3. Example
  4. TODO

Installation

npm install provide-authentication --save

Usage

provideAuthentication (Object provider)

Adds (or wraps/appends) the necessary actions, reducers, replication, etc. to the provider to enable authentication.

You can include the following extra arguments (in this order) to customize the action/reducer keys:

  • String name - defaults to provider.defaultKey, then provider.key, then "resource"
  • String idKey - defaults to "id"
  • String nameKey - defaults to "name"
  • String passwordKey - defaults to "password"
  • String errorKey - defaults to "error"
  • String createKey - defaults to "create"
  • String authenticateKey - defaults to "authenticate"
  • Boolean unique - defaults to true, ensures unique states for the nameKey, which is useful for things like unique user names and will authenticate based on the nameKey; if unique is false, authentication must occur by using the idKey; this argument is determined by checking the last argument, so you can disable uniqueness by including false as your last argument, regardless of the number of other arguments

The above defaults would create the following actions:

  • createResource (Object state)
  • authenticateResource (Object state)

And would expect the following reducers to exist:

  • resourceId
  • resourceName (ensures queryable replication if unique)

And would ensure that the following reducers exist:

  • resourceError
  • resourcePasswordHash (ensures replication)
  • resourcePasswordHasher (defaults to initial state only)
  • resourcePasswordSaltRounds (defaults to initial state only)

And would also ensure that resourceError is within clientStateKeys while excluding resourcePasswordHash, resourcePasswordHasher, and resourcePasswordSaltRounds by default.

Example

See provide-user, which first creates a user resource provider using provide-crud, and then adds authentication to it using this provider factory.

Also see Lumbur's UserLogIn component for usage.

TODO

2.0.0

7 years ago

2.0.0-rc.3

8 years ago

2.0.0-rc.2

8 years ago

2.0.0-rc.1

8 years ago

1.0.0-rc.9

8 years ago

1.0.0-rc.8

8 years ago

1.0.0-rc.7

8 years ago

1.0.0-rc.6

8 years ago

1.0.0-rc.5

8 years ago

1.0.0-rc.4

8 years ago

1.0.0-rc.3

8 years ago

1.0.0-rc.2

8 years ago

1.0.0-rc.1

8 years ago