feat: facebook auth module
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
))
|
||||
}
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user