township-reset-password-token

1.0.0 • Public • Published

township-reset-password-token

Manage tokens for resetting passwords

npm travis standard conduct

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

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

License

ISC

Package Sidebar

Install

npm i township-reset-password-token

Weekly Downloads

2

Version

1.0.0

License

ISC

Last publish

Collaborators

  • sethvincent