refactor: renderers + auth providers + fixes
This commit is contained in:
30
server/extensions/authentication/dropbox.js
Normal file
30
server/extensions/authentication/dropbox.js
Normal file
@@ -0,0 +1,30 @@
|
||||
/* global wiki */
|
||||
|
||||
// ------------------------------------
|
||||
// Dropbox Account
|
||||
// ------------------------------------
|
||||
|
||||
const DropboxStrategy = require('passport-dropbox-oauth2').Strategy
|
||||
|
||||
module.exports = {
|
||||
key: 'dropbox',
|
||||
title: 'Dropbox',
|
||||
useForm: false,
|
||||
props: ['clientId', 'clientSecret'],
|
||||
init (passport, conf) {
|
||||
passport.use('dropbox',
|
||||
new DropboxStrategy({
|
||||
apiVersion: '2',
|
||||
clientID: conf.clientId,
|
||||
clientSecret: conf.clientSecret,
|
||||
callbackURL: conf.callbackURL
|
||||
}, (accessToken, refreshToken, profile, cb) => {
|
||||
wiki.db.User.processProfile(profile).then((user) => {
|
||||
return cb(null, user) || true
|
||||
}).catch((err) => {
|
||||
return cb(err, null) || true
|
||||
})
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
31
server/extensions/authentication/oauth2.js
Normal file
31
server/extensions/authentication/oauth2.js
Normal file
@@ -0,0 +1,31 @@
|
||||
/* global wiki */
|
||||
|
||||
// ------------------------------------
|
||||
// OAuth2 Account
|
||||
// ------------------------------------
|
||||
|
||||
const OAuth2Strategy = require('passport-oauth2').Strategy
|
||||
|
||||
module.exports = {
|
||||
key: 'oauth2',
|
||||
title: 'OAuth2',
|
||||
useForm: false,
|
||||
props: ['clientId', 'clientSecret', 'authorizationURL', 'tokenURL'],
|
||||
init (passport, conf) {
|
||||
passport.use('oauth2',
|
||||
new OAuth2Strategy({
|
||||
authorizationURL: conf.authorizationURL,
|
||||
tokenURL: conf.tokenURL,
|
||||
clientID: conf.clientId,
|
||||
clientSecret: conf.clientSecret,
|
||||
callbackURL: conf.callbackURL
|
||||
}, (accessToken, refreshToken, profile, cb) => {
|
||||
wiki.db.User.processProfile(profile).then((user) => {
|
||||
return cb(null, user) || true
|
||||
}).catch((err) => {
|
||||
return cb(err, null) || true
|
||||
})
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user