refactor: renderers + auth providers + fixes

This commit is contained in:
NGPixel
2018-01-14 22:05:08 -05:00
parent 24fc806b0e
commit 74bd722168
41 changed files with 475 additions and 770 deletions

View 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
})
})
)
}
}

View 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
})
})
)
}
}