password-reset
middleware for managing password reset emails
example
var fs = ;var express = ;var app = express;app;app; // for sessionsvar forgot =uri : 'http://localhost:8080/password_reset'from : 'password-robot@localhost'host : 'localhost' port : 25;app;app;app;app;console;
methods
var forgot = require('password-reset')(opts)
Create a new password reset session forgot
with some options opts
.
opts.uri
must be the location of the password reset route, such as
'http://localhost:8080/_password_reset'
. A query string is appended to
opts.uri
with a unique one-time hash.
opts.body(uri)
can be a function that takes the password reset link uri
and
returns the email body as a string.
The rest of the options are passed directly to node-pony.
When the user clicks on the uri link forgot
emits a "request", req, res
event.
var reset = forgot(email, cb)
Send a password reset email to the email
address.
cb(err)
fires when the email has been sent.
forgot.middleware(req, res, next)
Use this middleware function to intercept requests on the opts.uri
.
forgot.expire(id)
Prevent a session from being used again. Call this after you have successfully reset the password.
attributes
reset.id
Pass this value to forgot.expire(id)
.
events
reset.on('request', function (req, res) { ... })
Emitted when the user clicks on the password link from the email.
reset.on('failure', function (err) { ... })
Emitted when an error occurs sending email. You can also listen for this event
in forgot()
's callback.
reset.on('success', function () {})
Emitted when an email is successfully sent.
install
With npm do:
npm install password-reset
license
MIT/X11