provide-authentication v2.0.0
provide-authentication
Provider factory for authenticating to some resource.
Table of contents
Installation
npm install provide-authentication --saveUsage
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 toprovider.defaultKey, thenprovider.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 totrue, ensures unique states for thenameKey, which is useful for things like unique user names and will authenticate based on thenameKey; ifuniqueis false, authentication must occur by using theidKey; this argument is determined by checking the last argument, so you can disable uniqueness by includingfalseas 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:
resourceIdresourceName(ensures queryable replication ifunique)
And would ensure that the following reducers exist:
resourceErrorresourcePasswordHash(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
- Changing password
- Resetting password
- What do you deem necessary?
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago