New plugin API.
This commit is contained in:
parent
ad06c8147f
commit
b31f55063d
@ -2,14 +2,39 @@ import {OAuth2Strategy as Strategy} from 'passport-google-oauth'
|
||||
|
||||
// ===================================================================
|
||||
|
||||
export const configurationSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
callbackURL: {
|
||||
type: 'string',
|
||||
description: 'Must be exactly the same as specified on the Google developer console.'
|
||||
},
|
||||
clientID: {
|
||||
type: 'string'
|
||||
},
|
||||
clientSecret: {
|
||||
type: 'string'
|
||||
}
|
||||
},
|
||||
required: ['callbackURL', 'clientID', 'clientSecret']
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
|
||||
class AuthGoogleXoPlugin {
|
||||
constructor (conf) {
|
||||
constructor (xo) {
|
||||
this._xo = xo
|
||||
}
|
||||
|
||||
configure (conf) {
|
||||
conf.scope = 'https://www.googleapis.com/auth/plus.login'
|
||||
|
||||
this._conf = conf
|
||||
}
|
||||
|
||||
load (xo) {
|
||||
load () {
|
||||
const {_xo: xo} = this
|
||||
|
||||
xo.registerPassportStrategy(new Strategy(this._conf, async (accessToken, refreshToken, profile, done) => {
|
||||
try {
|
||||
console.log(profile)
|
||||
@ -23,4 +48,4 @@ class AuthGoogleXoPlugin {
|
||||
|
||||
// ===================================================================
|
||||
|
||||
export default conf => new AuthGoogleXoPlugin(conf)
|
||||
export default ({xo}) => new AuthGoogleXoPlugin(xo)
|
||||
|
Loading…
Reference in New Issue
Block a user