@airplanegobrr/express-login
v1.0.4
Published
Login middleware for express (DO NOT USE IN PRODUCTION)
Downloads
10
Readme
Express-login
⚠⚠ DO NOT USE THIS MODULE IN PRODUCTION! ⚠⚠
This module should NOT be used in real production! It contains bad security and is STRONGLY not recommended!
Example
const express = require('express');
const expressLoginClass = require('@airplanegobrr/express-login')
const login = new expressLoginClass({
title: "Login",
discord: {
discordURL: "https://discord.com/api/oauth2/authorize?client_id=793281470696652821&redirect_uri=http://localhost:3001/discordAuth&response_type=code&scope=identify email connections guilds",
secret: "No",
id: "793281470696652821",
redirect: "http://localhost:3001/discordAuth"
}
}, "no.", "password")
const app = express()
app.use(express.json());
app.use(login.runner)
app.get('/', (req, res) => {
res.send("Hi!")
})
app.get("/super-secure-resource", (req, res) => {
//Just check for req.auth if it is true we are logged it and its a real user
if (req.auth) {
res.send(`<h1>Welcome back ${req.authInfo.user}!</h1>`)
} else {
res
.status(401)
.json({ message: "You need to be logged in to access this resource" });
}
});
app.listen(3001, ()=>{
console.log("Server on")
})