Skip to content

Commit

Permalink
release 4.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
pofider committed Dec 11, 2023
1 parent d250169 commit 00be95e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
17 changes: 9 additions & 8 deletions lib/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const FacebookStrategy = require('passport-facebook').Strategy
const TwitterStrategy = require('passport-twitter').Strategy
const GitHubStrategy = require('passport-github').Strategy
const slugify = require('slugify')
const Promise = require('bluebird')
const ObjectId = require('mongodb').ObjectId
const pkg = require('../package.json')
const nanoid = require('nanoid')
Expand All @@ -28,45 +27,47 @@ module.exports = (reporter, definition, app) => {
clientSecret: definition.options.github.clientSecret,
callbackURL: (definition.options.baseUrl || 'http://localhost:5488') + '/login/github/return'
}, (accessToken, refreshToken, profile, cb) => {
Promise.resolve(playground.findOrInsertUser({
playground.findOrInsertUser({
username: profile.username,
fullName: profile.displayName,
externalId: profile.id,
provider: 'github'
})).asCallback(cb)
}).then(r => cb(null, r)).catch(e => cb(e))
}))

passport.use(new FacebookStrategy({
clientID: definition.options.facebook.clientID,
clientSecret: definition.options.facebook.clientSecret,
callbackURL: (definition.options.baseUrl || 'http://localhost:5488') + '/login/facebook/return'
}, (accessToken, refreshToken, profile, cb) => {
Promise.resolve(playground.findOrInsertUser({
playground.findOrInsertUser({
username: slugify(profile.displayName, {
replacement: '.',
lower: true
}),
fullName: profile.displayName,
externalId: profile.id,
provider: 'facebook'
})).asCallback(cb)
}).then(r => cb(null, r)).catch(e => cb(e))
}))

passport.use(new TwitterStrategy({
consumerKey: definition.options.twitter.consumerKey,
consumerSecret: definition.options.twitter.consumerSecret,
callbackURL: (definition.options.baseUrl || 'http://localhost:5488') + '/login/twitter/return'
}, (token, tokenSecret, profile, cb) => {
Promise.resolve(playground.findOrInsertUser({
playground.findOrInsertUser({
username: profile.username,
fullName: profile.displayName,
externalId: profile.id,
provider: 'twitter'
})).asCallback(cb)
}).then(r => cb(null, r)).catch(e => cb(e))
}))

passport.serializeUser((user, cb) => cb(null, user._id))
passport.deserializeUser((obj, cb) => Promise.resolve(playground.findUser({ _id: obj })).asCallback(cb))
passport.deserializeUser((obj, cb) => {
playground.findUser({ _id: obj }).then(r => cb(null, r)).catch(e => cb(e))
})

app.use(sessions({
cookieName: 'session',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "playground-server",
"version": "4.2.0",
"version": "4.2.2",
"private": true,
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 00be95e

Please sign in to comment.