0.0.2 • Published 8 years ago
cf-password-reset-token v0.0.2
cf-password-reset-token
Generate and validate password reset tokens
Installation
npm install --save cf-password-reset-tokenUsage
var passwordResetToken = require('cf-password-reset-token')
// Generate a token for an authable entity (i.e one that can authorize
// themself with the system – e.g. administrator, user, customer)
passwordResetToken.generate(authableEntity)
//-> { token: '...', expiry: '...'}
// Check that a password reset token is valid for a given authable entity
passwordResetToken.validate(authableEntity, token)
//-> true or falseAPI
var t = require('cf-password-reset-token')
t.generate(Object: authableEntity, Object: options)
authableEntity must have the following properties: created and password, along
with an identity property that be configured with options.identityProperty. This
defaults to 'emailAddress'. options.expiry can be used to configure how long the
token is valid for. The default is 1 hour.
t.validate(Object: authableEntity, Object: token)
authableEntity is the entity that token should be validated against. This function
will return true if both of the following conditions are met:
token.tokenis a valid tokentoken.expiryis not in the past- Certain properties of
authableEntityare the same as when the token was created:created,passwordand itsidentityProperty
Credits
Built by developers at Clock.
Licence
Licensed under the New BSD License
0.0.2
8 years ago
0.0.1-support
8 years ago