express-passport-ldap-mongoose
Advanced tools
Comparing version 3.1.0 to 3.1.1
module.exports = { | ||
dburl : 'mongodb://localhost/ldaptest', | ||
mongodb: { | ||
url: 'mongodb://localhost/ldaptest', | ||
}, | ||
sessionSecret: 'ZXaffeqe123!$2', | ||
ldap: { | ||
dn: 'dc=example,dc=com', | ||
url: 'ldap://ldap.forumsys.com' | ||
} | ||
} | ||
url: 'ldap://ldap.forumsys.com', | ||
}, | ||
} |
@@ -7,9 +7,11 @@ /* jshint node:true */ | ||
mongoose.Promise = Promise | ||
mongoose.connect(CONFIG.dburl, { | ||
useUnifiedTopology: true, | ||
useNewUrlParser: true, | ||
useFindAndModify: false, | ||
}) | ||
const mongoClientPromise = mongoose | ||
.connect(CONFIG.mongodb.url, { | ||
user: CONFIG.mongodb.user, | ||
pass: CONFIG.mongodb.pass, | ||
authSource: 'admin', | ||
}) | ||
.then((m) => m.connection.getClient()) | ||
const session = require('express-session') | ||
const MongoStore = require('connect-mongo')(session) | ||
const MongoStore = require('connect-mongo') | ||
@@ -25,3 +27,5 @@ const express = require('express') | ||
secret: CONFIG.sessionSecret, | ||
store: new MongoStore({ mongooseConnection: mongoose.connection }), | ||
store: MongoStore.create({ | ||
clientPromise: mongoClientPromise, | ||
}), | ||
resave: true, | ||
@@ -83,8 +87,14 @@ saveUninitialized: true, | ||
(id) => User.findOne({ username: id }).exec(), | ||
(user) => { | ||
async (user) => { | ||
console.log(`${user[usernameAttr]} has logged in`) | ||
return User.findOneAndUpdate({ username: user[usernameAttr] }, user, { | ||
upsert: true, | ||
new: true, | ||
}).exec() | ||
let foundUser = await User.findOneAndUpdate( | ||
{ username: user[usernameAttr] }, | ||
user, | ||
{ | ||
upsert: true, | ||
new: true, | ||
} | ||
).exec() | ||
console.log(`${foundUser.username} is retrieved from database`) | ||
return foundUser | ||
} | ||
@@ -91,0 +101,0 @@ ) |
@@ -48,3 +48,2 @@ /** | ||
} | ||
_router = router | ||
_findFunc = findFunc | ||
@@ -51,0 +50,0 @@ _insertFunc = insertFunc |
{ | ||
"name": "express-passport-ldap-mongoose", | ||
"version": "3.1.0", | ||
"description": "A library to use passport-ldapauth and local MongoDB to authenticate and save users", | ||
"version": "3.1.1", | ||
"description": "A library to use ldap-authentication and passport to authenticate users", | ||
"main": "index.js", | ||
@@ -10,19 +10,18 @@ "repository": "https://github.com/shaozi/express-passport-ldap-mongoose.git", | ||
"dependencies": { | ||
"ldap-authentication": "^2.2.7", | ||
"passport": "^0.4.1", | ||
"ldap-authentication": "^2.2.9", | ||
"passport": "^0.5.2", | ||
"passport-custom": "^1.1.1" | ||
}, | ||
"devDependencies": { | ||
"connect-mongo": "^3.2.0", | ||
"express": "^4.17.1", | ||
"express-session": "^1.17.1", | ||
"jasmine": "^3.7.0", | ||
"jasmine-console-reporter": "^3.1.0", | ||
"mongoose": "^5.9.18", | ||
"superagent": "^5.2.2", | ||
"supertest": "^4.0.2" | ||
"connect-mongo": "^4.6.0", | ||
"express": "^4.18.0", | ||
"express-session": "^1.17.2", | ||
"jasmine": "^4.1.0", | ||
"mongoose": "^6.3.1", | ||
"superagent": "^7.1.2", | ||
"supertest": "^6.2.2" | ||
}, | ||
"scripts": { | ||
"test": "node test/jasmine.js" | ||
"test": "jasmine" | ||
} | ||
} |
@@ -148,6 +148,9 @@ # express-passport-ldap-mongoose | ||
app, | ||
(id) => { | ||
return User.findOne({ usernameAttributeName: id }).exec() | ||
}, (user) => { | ||
return User.findOneAndUpdate({ username: user[usernameAttributeName] }, user, { upsert: true, new: true }).exec() | ||
async (id) => { | ||
let user = await User.findOne({ usernameAttributeName: id }).exec() | ||
return user | ||
}, | ||
async (user) => { | ||
let foundUser = await User.findOneAndUpdate({ username: user[usernameAttributeName] }, user, { upsert: true, new: true }).exec() | ||
return foundUser | ||
}) | ||
@@ -154,0 +157,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25503
7
15
469
164
+ Addedpassport@0.5.3(transitive)
- Removedpassport@0.4.1(transitive)
Updatedldap-authentication@^2.2.9
Updatedpassport@^0.5.2