About
sql_user_manager is a complete drop-in middleware solution for user management. sql_user_manager is Express middleware and is compatible with any database supported by Knex (Postgres, MSSQL, MySQL, MariaDB, SQLite3, and Oracle). sql_user_manager also provides optional Knex backed session management via connect-session-knex.
sql_user_manager supports the following featues:
- Registration
- Login
- Logout
- Email Confirmation
- Password reset
- Session management(optional)
Screenshots
Depedencies
sql_user_manager requires an initialized Knex object and an initialized (Nodemailer)[https://github.com/nodemailer/nodemailer] tansporter (to handle password resets and email confirmations).
Example Usage
var app = var knex = var bodyParser = var secret = ; // nodemailer SMTP config var nodemailer = ;var smtpTransport = ; var transporter = nodemailer; var dbCreds = client: 'mysql' connection: host: 'localhost' user: 'root' password: 'root' database: 'sql_login' port: 8889 var knex = dbCreds var sqlLoginMiddleware = app rootUrl: 'http://localhost:3010/test' knex: knex transporter: transporter siteName: 'Test Site' sessionSecret: 'super duper secret' loginSuccessRedirect: 'http://localhost:3010/test'; app;app; app; var server = app
Documentation
Session info
After registration or login, session will include a user object with a user.id
property (you can check this to determin if the user is logged in)
Initialization:
npm install sql_user_manager
var sqlUserManager = require('sql_user_manager')(app, options);
Options
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.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.termsLink
- optional - link for terms if requireTerms
is used
options.tablename
- optional - defatuls to 'sql_user_manager'
options.transporter
- required - Nodemail transporter
options.siteName
- required - name of site
Template Options
options.bodyBottom
- optional - string that gets injected at the bottom of the body on any sql_user_manager pages
options.bodyTop
- optional - string that gets injected at the top of the body on any sql_user_manager pages
options.header
- optional - string that gets injected into the header of all sql_user_manager pages
Testing
node ./test/index.js
Todo
- add brute force check
- add optional terms checkbox and link for registration
- add api routes for all existint routes