npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node_express_user_manager

v0.1.1

Published

node_express_user_manager is a complete drop-in solution for user management. node_express_user_manager is [Express](https://expressjs.com/) middleware and is compatible with any database supported by [Knex](http://knexjs.org/) (Postgres, MSSQL, MySQL, Ma

Downloads

9

Readme

About

node_express_user_manager is a complete drop-in solution for user management. node_express_user_manager is Express middleware and is compatible with any database supported by Knex (Postgres, MSSQL, MySQL, MariaDB, SQLite3, and Oracle) or RethinkDB. node_express_user_manager also provides optional session management via connect-session-knex for SQL and express-session-rethinkdb for RethinkDB.

node_express_user_manager supports the following featues:

  • Registration
  • Login
  • Logout
  • Brute force login prevention
  • Email confirmation(cofirms user's email)
  • Password reset
  • Session management(optional)

Screenshots

Register

Register Errors

Login

Password Reset

Profile Update

Dependencies

node_express_user_manager requires an initialized Knex object or RethinkDB connection configuration and an initialized Nodemailer tansporter (to handle password resets and email confirmations).

Example Usage

var app = require('express')()

var knex = require('knex')
var bodyParser = require('body-parser')
var secret = require('../secret'); // nodemailer SMTP config

var nodemailer = require('nodemailer');
var smtpTransport = require('nodemailer-smtp-transport');

var transporter = nodemailer.createTransport(smtpTransport(secret.smtp));

var dbCreds = {
    client: 'mysql',
    connection: {
        host: 'localhost',
        user: 'root',
        password: 'root',
        database: 'sql_login',
        port:  8889
    }
}

var knex = require('knex')(dbCreds)

var userManager = require('node_express_user_manager')(app, {
    rootUrl: 'http://localhost:3010/user', // should match the middleware root
    knex: knex,
    transporter: transporter,
    siteName: 'Test Site',
    sessionSecret: 'super duper secret',
    loginSuccessRedirect: 'http://localhost:3010/success'
});

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));

app.use('/user', userManager);

var server = app.listen(80, function () {
    var host = server.address().address
    var port = server.address().port

    console.log("Example app listening at http://%s:%s", host, port)
})

Example RehtinkDB config

var options = {
    rootUrl: 'http://localhost:3010/user', // should match the middleware root
    rethinkConnectionOptions: {
        db: 'db_auth_test',
        host: '127.0.0.1',
        port: '28015'
    },
    databaseName: 'db_auth_test',
    tableName: 'db_auth_test_table',
    transporter: transporter,
    siteName: 'Test Site',
    sessionSecret: 'super duper secret',
    loginSuccessRedirect: 'http://localhost:3010/success'
}

var userManager = require('../index')(app, options);

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));

app.use('/user', userManager);

Documentation

Session info

After registration or login, session will include a user object with a user.id property (you can check this to determine if the user is logged in)

Initialization:

npm install node_express_user_manager

var userManager = require('node_express_user_manager')(app, options);

Options

options.databaseName - required if using RethinkDB

options.knex - required - initialized Knex object

options.loginSuccessRedirect - optional - url to redirect user to after successful login

options.manageSessions - optional - defaults to true. If true, user sessions get stored in DB

options.registerSuccesRedirect - optional - url to redirect user to after registration

options.rethinkConnectionOptions - required if using RethinkDB - see connection optionsjavascript/

options.requireTerms - optional - if true, registration will include a checkbox that user's are required to check indicating they agree to the terms

options.sessionSecret - required if useing manageSessions

options.sessionExpiration - optional - session expiration in ms, defaults to 12 hours

options.sessionSaveUninitialized - optional - defaults to false

options.sessionResave - optional - defaults to false

options.siteName - required - name of site

options.tablename - optional - defatuls to 'node_express_user_manager'

options.termsLink - optional - link for terms if requireTerms is used

options.transporter - required - Nodemail transporter

Template Options

options.bodyBottom - optional - string that gets injected at the bottom of the body on any node_express_user_manager pages

options.bodyTop - optional - string that gets injected at the top of the body on any node_express_user_manager pages

options.header - optional - string that gets injected into the header of all node_express_user_manager pages

Todo

  • send confirmation email on register
  • add optional terms checkbox and link for registration
  • add api routes for all existing routes