pass-reset
An express compatable module for creating RESTful password reset endpoints.
Install
$ npm install pass-reset
Configuration
Example expiration
var passReset = ; // The unit (second param) can be one of the following (or undefined for milliseconds):// "secs", "mins", "hours", "days", or "weeks"passReset;
Example user lookup routine
var passReset = ; passReset;
Example set password routine
var passReset = ; passReset;
Example send email routine
var passReset = ; var template = handlebars; passReset;
Example custom storage for tokens
var passReset = ;var redis = ; passResetstorage;
Usage
Route for requesting a new reset token
app;
The requestResetToken
method can also take an object of configuration values. The following values are supported:
- loginParam - The name of the param where the login data (username/email) can be found in
req.body
. - callbackURL - The base URL to direct users to actually perform the reset. This value should contain a
"{token}"
somewhere which will be replaced with the token, eg."/password/reset/{token}"
. - next - By default, when pass-reset is done generating a token and sending it, an empty 200 OK response will be sent. To change this behavior, this value can be given a few different values. If a string is given, it is treated as a redirect, if a function is given, it will be called with the
req
,res
, andnext
parameters, and if any other truthy value is given, thenext
function will simply be called.
app;
Route for actually reseting passwords
app;
The resetPassword
method can also take an object of configuration values. The following values are supported:
- tokenParam/passwordParam/confirmParam - The name of the params where the respective data (token/password/confirm) can be found in
req.body
. - next - By default, after the password is reset, an empty 200 OK response will be sent. To change this behavior, this value can be given a few different values. If a string is given, it is treated as a redirect, if a function is given, it will be called with the
req
,res
, andnext
parameters, and if any other truthy value is given, thenext
function will simply be called.
app;