Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-forgot-password

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-forgot-password - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

3

app.js
var express = require('express')
, ForgotPassword = require('./model')(mongoose)
module.exports = function(config, mongoose, Customer){
module.exports = function(ForgotPassword, Customer){

@@ -6,0 +5,0 @@ var app = express()

module.exports = function(opts){
if (! opts.mongoose ) {
throw "express-forgot-password needs a connected mongoose object"
}
if (! opts.mailFrom )
opts.mailFrom = "No Reply <noreply@noreply.com>"
if (! opts.resetMailSubject )
opts.resetMailSubject = "Reset your password"
if (! opts.mailConfig )
throw "express-forgot-password needs config for nodemailer"
if (! opts.resetMailContent )
throw "express-forgot-password needs a function resetMailContent(user, token) to supply the email body"
var model = require('./model')(
opts.mongoose
, opts.mailConfig
, opts.mailFrom
, opts.resetMailSubject
, opts.resetMailContent
)
return {
app : require('./app')(opts.config, opts.mongoose, opts.user)
app : require('./app')(model, opts.user)
}
}
var crypto = require('crypto')
, mailer = require('nodemailer')
module.exports = function(mongoose) {
module.exports = function(mongoose, mailConfig, mailFrom, resetMailSubject, resetMailContent) {
var Schema = mongoose.Schema

@@ -23,3 +23,3 @@

if (Date.now() - forgot.sent > config.forgotpassword_expiry){
if (Date.now() - forgot.sent > (1000*60*60*12)){
return cb("Invalid Code: Expired")

@@ -55,6 +55,12 @@ }

console.log(">>> ForgotPassword sent:", customer.email)
customer.sendEmail(
"Reset your password for Hosted Strider"
, 'customer-forgot-email.html'
, { token : forgot.code}, cb)
var emailTransport = mailer.createTransport("SMTP", mailConfig)
var envelope = {
from: mailFrom
, to: customer.email
, subject: resetMailSubject
, text: resetMailContent(customer, '/reset-password?id=' + forgot.code)
}
emailTransport.sendMail(envelope, cb)
})

@@ -65,4 +71,5 @@

var ForgotPassword = mongoose.model('ForgotPassword', ForgotPasswordSchema)
return Forgot Password
return ForgotPassword
}
{
"name": "express-forgot-password",
"version": "0.1.0",
"version": "0.2.0",
"description": "Express Forgotton Password sub-app",

@@ -13,4 +13,5 @@ "main": "index.js",

"express": "~3.4.0",
"mongoose": "~3.6.20"
"mongoose": "~3.6.20",
"nodemailer": "~0.5.2"
}
}

@@ -8,2 +8,4 @@ # Forgot Password Flow

- User model has `.findByEmail`
- config.mailConfig : nodemailer
- config.name : app name

@@ -14,5 +16,14 @@ ## Usage:

var forgotton = require('express-forgotton-password')({ config: config, mongoose: mongoose, user : UserModel }) // Passing mongoose here _sucks_
var forgotton = require('express-forgotton-password')({
// None of this is optional :(
mailConfig: config // config for nodemailer
, mailFrom: "nomail" // mailer from address
, mongoose: mongoose // Passing mongoose here _sucks_
, resetMailSubject : "Reset yout mysite password"
, resetMailContent : function(user, token){
return "reset link: http://mysite" + token + " \n thanks"
}
, user : UserModel })
app.use(forgotton.app)
```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc