New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

express-account-pages

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-account-pages

An abstraction middleware for Express for user management on top of Passport

  • 1.1.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

express-account-pages

npm i express-account-pages

A simple to use module for Express that handles authentification (signup and login) and provide a basic account page you can place in your app.

Requires JQuery and Bootstrap 4 (JS + CSS) on the client side.

Features

  • OAuth (Google and Github)
  • Drop-in login/signup page
  • Drop-in account management page
  • Logged middleware
  • Ability to disable sign ups
  • Use Bootstrap
  • Magic link option
  • Store last logged date for users

Who uses it?

NucleusElioPayBackeryLttrfeed

👋 Want to be listed there? Contact me.

Usage


// Init express
const express 		= require('express')
const app 			= express()

// Add your DB
const mongoose      = require('mongoose')
const mongoURI 		= process.env.MONGO_URL || 'mongodb://localhost:27017/myappdb'
mongoose.connect(mongoURI, { useNewUrlParser: true })

// Your db schmeas
const db 			= require('./helpers/db')

// Parse from html forms and post payload
app.use(express.json()) 
app.use(express.urlencoded({ extended: true }))

// For signup and login
require('express-account-pages')(app, {
	siteName: 'My Web App',
	primaryColor: '#b90577',
	// background: 'red',
	// logoUrl: '/favicon.png',
	mongoose: mongoose,
	useAccessToken: true, // Access token management
	redirectLogin: '/account',
	redirectSignup: '/account',
	// disableSignup: true,
	// signupMailExtra: 'You can now create your first app.',
	mongoUser: db.User,
	connectors: {
		github: {
			clientId: "xxxxxxx",
			clientSecret: "xxxxxx",
			redirectUri: "https://my.app/auth/github/callback"
		},
		google: {
			clientId: 'xxxxxxx.apps.googleusercontent.com',
			clientSecret: 'xxxxxxxxx',
			redirectUri: 'https://my.app/auth/google/callback'
		}
	}
})

Account page

Will require Bootstrap and jQuery.

In your express route:

app.get("/account", (req, res, next) => {

	res.render("my_account_view", { // Where account is your page structure
		accountTemplate: require.resolve("express-account-pages/account.ejs")
	})
})

Make sure to have Bootstrap.js and jQuery included. Then, in your ejs:

<body>
	<%- include(accountTemplate) %>
</body>

<script src="/account/account.js" defer></script>

Oauth

Currently the module supports Github and Google oauth.

The redirect URIs are predefined paths:

  • /auth/github/callback for Github
  • /auth/google/callback for Github

FAQs

Package last updated on 31 Jul 2019

Did you know?

Socket

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.

Install

Related posts

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