Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
mongoose-emailable
Advanced tools
Mongoose plugin for email with confirmation and express middleware
Mongoose plugin for email address confirmation and express route: automatically sends an email with a "click to confirm address" link to a just-registered user, or to a user that changes its email address.
Clicking the link will flag the email address as "confirmed", thus allowing mails to be sent to this address. No other mails beside the "confirm your address" will be sent to an unconfirmed address.
This module internally uses nodemailer module with Amazon SES transport.
npm install mongoose-emailable
Setting up mongoose-emailable is pretty straightfoward:
# User model file...
mongoose = require("mongoose")
emailablePlugin = require("mongoose-emailable").plugin
UserSchema = new mongoose.Schema(
name:
type: String
required: true
)
UserSchema.plugin(emailablePlugin,
from: "Example.com <no-reply@example.com>" # Any email address you own
confirmRoute: "https://example.com/account/email/confirm" # Query string will be automatically added
amazonSES:
AWSAccessKeyID: "..."
AWSSecretKey: "..."
)
express = require("express")
emailableRoutes = require("mongoose-emailable").routes
UserModel = require("./path/to/your/mongoose/usermodel")
app = express()
emailableRoutes.use(app,
model: UserModel # mandatory
)
And you're set! Users will receive an email asking for confirmation when registering.
Settings
from
: the sender email address, typically your addressconfirmRoute
: path to your server address route (ie. http://example.com/account/email/confirm)amazonSES
: an object with AWSAccessKeyID
and AWSSecretKey
keysOptions
subject
: a string
used to populate the email subject (defaults to "Confirm your account registration")html
: a function
or string
used to populate the email body (defaults: see source code)model
: any mongoose model class, most likely a User model kind.path
: path to email confirmation page (default: /account/email/confirm)template
: template to use when rendering the email confirmation page (defaults to a simple text page)reqHttpFields
: any fields in express req
object that you wish to automatically pass to res.locals
. Simply pass an object where keys are req
fields and values are res.locals
fields (for example, passing { user: loggedUser }
will set the value of req.user
to res.locals.loggedUser
.middlewares
: array of express middlewares you wish to pass to the route.Asynchronously sends an email to any confirmed email address.
See nodemailer documentation for a full description of message object.
name
fieldFAQs
Mongoose plugin for email with confirmation and express middleware
The npm package mongoose-emailable receives a total of 3 weekly downloads. As such, mongoose-emailable popularity was classified as not popular.
We found that mongoose-emailable demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.