Provider factory for authenticating to some resource.
Table of contents
npm install provide-authentication --save
provideAuthentication (Object provider)
Adds (or wraps/appends) the necessary
replication, etc. to the
provider to enable authentication.
You can include the following extra arguments (in this order) to customize the action/reducer keys:
name- defaults to
provider.key, then "resource"
idKey- defaults to "id"
nameKey- defaults to "name"
passwordKey- defaults to "password"
errorKey- defaults to "error"
createKey- defaults to "create"
authenticateKey- defaults to "authenticate"
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
uniqueis false, authentication must occur by using the
idKey; this argument is determined by checking the last argument, so you can disable uniqueness by including
falseas your last argument, regardless of the number of other arguments
The above defaults would create the following
createResource (Object state)
authenticateResource (Object state)
And would expect the following
reducers to exist:
resourceName(ensures queryable replication if
And would ensure that the following
resourcePasswordHasher(defaults to initial state only)
resourcePasswordSaltRounds(defaults to initial state only)
And would also ensure that
resourceError is within
clientStateKeys while excluding
resourcePasswordSaltRounds by default.
Also see Lumbur's UserLogIn component for usage.
- Changing password
- Resetting password
- What do you deem necessary?