New plugin API.
This commit is contained in:
parent
84c9532456
commit
25873e0e02
@ -2,12 +2,33 @@ import {Strategy} from 'passport-github'
|
||||
|
||||
// ===================================================================
|
||||
|
||||
export const configurationSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
clientID: {
|
||||
type: 'string'
|
||||
},
|
||||
clientSecret: {
|
||||
type: 'string'
|
||||
}
|
||||
},
|
||||
required: ['clientID', 'clientSecret']
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
|
||||
class AuthGitHubXoPlugin {
|
||||
constructor (conf) {
|
||||
constructor (xo) {
|
||||
this._xo = xo
|
||||
}
|
||||
|
||||
configure (conf) {
|
||||
this._conf = conf
|
||||
}
|
||||
|
||||
load (xo) {
|
||||
load () {
|
||||
const {_xo: xo} = this
|
||||
|
||||
xo.registerPassportStrategy(new Strategy(this._conf, async (accessToken, refreshToken, profile, done) => {
|
||||
try {
|
||||
done(null, await xo.registerUser('github', profile.username))
|
||||
@ -20,4 +41,4 @@ class AuthGitHubXoPlugin {
|
||||
|
||||
// ===================================================================
|
||||
|
||||
export default conf => new AuthGitHubXoPlugin(conf)
|
||||
export default ({xo}) => new AuthGitHubXoPlugin(xo)
|
||||
|
Loading…
Reference in New Issue
Block a user