township-reset-password-token
v1.0.0
Published
Manage JWT tokens for resetting passwords
Downloads
27
Maintainers
Readme
township-reset-password-token
Manage tokens for resetting passwords
About
A common part of using passwords for authentication includes resetting passwords and receiving an email with a special link that let's you reset the password.
This module takes care of generating and validating the tokens you use in the special links that get emailed out.
Install
npm install --save township-reset-password-token
Usage
var memdb = require('memdb')
var townshipResetPassword = require('township-reset-password-token')
var db = memdb()
var reset = townshipResetPassword(db, {
secret: 'not a secret' // passed to jsonwebtoken
})
reset.create({ accountKey: 'key for an account' }, function (err, token) {
if (err) return console.log(err)
// typically would send the token as part of a link in an email
// token would then be received by the server in an http request
reset.confirm({ accountKey: 'key for an account', token: token }, function (err) {
if (err) return console.log('token not confirmed', err)
console.log('token confirmed')
})
})
Documentation
Examples
- Basic usage
- client/server demo example
Contributing
Contributions are welcome! Please read the contributing guidelines first.
Conduct
It's important that this project contributes to a friendly, safe, and welcoming environment for all, particularly for folks that are historically underrepresented in technology. Read this project's code of conduct