Manage tokens for resetting passwords
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.
npm install --save township-reset-password-token
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')
})
})
- Basic usage
- client/server demo example
Contributions are welcome! Please read the contributing guidelines first.
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