Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
express-account-block
Advanced tools
A simple to use module for Express that handles authentification (signup and login), sessions and provide an account page you can place in your app.
Requires JQuery and Bootstrap 4 (JS + CSS) on the client side.
Nucleus | ElioPay | Backery | Anygoal | Lttrfeed | Musli.io |
👋 Want to be listed there? Contact me.
npm i express-account-block
Then in your express code
// 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-block')(app, {
siteName: 'My Web App',
siteUrl: 'example.com',
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'
}
},
pages: {
logoUrl: '/logo.png',
customHeadHtml: `
<link href="https://fonts.googleapis.com/css?family=Muli:400,800,900&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="/css/login.css">
`,
// login: {
// title: 'Good to have you back',
// subtitle: 'Sign in and keep rocking your companies goals.'
// },
}
})
// Then you can use the provided middleware to enforce user to be logged
// Redirects to login and back to page if not logged
// Supports API token access
// User object will be assigned to res.locals.user
const logged = require('express-account-block/logged')(db.User)
app.get('/dashboard', logged, (req, res, next) => {
const user = res.locals.user
...
})
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-block/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>
Currently the module supports Github and Google oauth.
The redirect URIs are predefined paths:
FAQs
User accounts middleware for Express on top of Passport
We found that express-account-block 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
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.