feat: facebook auth module

This commit is contained in:
Nick
2019-04-28 02:11:38 -04:00
parent 2abecea09c
commit c03dae933f
3 changed files with 32 additions and 15 deletions

View File

@@ -5,6 +5,7 @@
// ------------------------------------
const FacebookStrategy = require('passport-facebook').Strategy
const _ = require('lodash')
module.exports = {
init (passport, conf) {
@@ -13,13 +14,21 @@ module.exports = {
clientID: conf.clientId,
clientSecret: conf.clientSecret,
callbackURL: conf.callbackURL,
profileFields: ['id', 'displayName', 'email']
}, function (accessToken, refreshToken, profile, cb) {
WIKI.models.users.processProfile(profile).then((user) => {
return cb(null, user) || true
}).catch((err) => {
return cb(err, null) || true
})
profileFields: ['id', 'displayName', 'email', 'photos'],
authType: 'reauthenticate'
}, async (accessToken, refreshToken, profile, cb) => {
try {
const user = await WIKI.models.users.processProfile({
profile: {
...profile,
picture: _.get(profile, 'photos[0].value', '')
},
providerKey: 'facebook'
})
cb(null, user)
} catch (err) {
cb(err, null)
}
}
))
}

View File

@@ -5,16 +5,18 @@ author: requarks.io
logo: https://static.requarks.io/logo/facebook.svg
color: indigo
website: https://facebook.com/
isAvailable: false
isAvailable: true
useForm: false
scopes:
- email
props:
clientId:
type: String
title: Client ID
hint: Application Client ID
title: App ID
hint: Application ID
order: 1
clientSecret:
type: String
title: Client Secret
hint: Application Client Secret
title: App Secret
hint: Application Secret
order: 2