1.4.0 • Published 5 years ago
express-user-auth v1.4.0
express-user-auth
Quickly add user authentication to your Express app
- Works with any database
- Password hash stored using bcrypt
- Password reset functionality
- TODO: Login with Facebook, Twitter, Google, or Github
Install
npm i express express-user-authRequirements
Your createUser and updateUser methods must be able to save the following fields:
passwordHashpasswordAlgopasswordResetToken
Usage
import express from 'express'
import auth from 'express-user-auth'
const app = express()
// all functions are async and should return a Promise
app.use('/', auth({
sessionSecret: 'XXXX',
jwtSecret: 'XXXX',
createUser: function (user) { return user },
getUserByUsername: function (username) { return user },
updateUser: function (data) { return user },
sendPasswordReset: function ({ user, uri }) { },
passwordResetRedirectURL: '/'
}))
app.listen(3000)Routes
express-user-auth creates the following routes:
GET /registerGET /loginGET /forgot-passwordGET /reset-passwordPOST /registerPOST /loginPOST /send-password-resetPOST /reset-password
Screenshots
You get this UI out of the box: