From 8542959ec7a0a49702e8285d539f6f3e3bdf786c Mon Sep 17 00:00:00 2001 From: Syffs Date: Mon, 5 Mar 2018 18:06:48 +0100 Subject: [PATCH] feat: allow providers params to be overloaded from nuxt.config.js (#77) --- examples/demo/nuxt.config.js | 4 +++- lib/auth/providers/_utils.js | 2 +- lib/module.js | 10 +++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/examples/demo/nuxt.config.js b/examples/demo/nuxt.config.js index b1899a73c..50aa064a6 100644 --- a/examples/demo/nuxt.config.js +++ b/examples/demo/nuxt.config.js @@ -33,7 +33,9 @@ module.exports = { client_id: 'q8lDHfBLJ-Fsziu7bf351OcYQAIe3UJv' }, facebook: { - client_id: '1671464192946675' + client_id: '1671464192946675', + userinfo_endpoint: 'https://graph.facebook.com/v2.12/me?fields=about,name,picture{url},email,birthday', + scope: ['public_profile', 'email', 'user_birthday'] }, google: { client_id: diff --git a/lib/auth/providers/_utils.js b/lib/auth/providers/_utils.js index eed187035..ea401820c 100644 --- a/lib/auth/providers/_utils.js +++ b/lib/auth/providers/_utils.js @@ -2,7 +2,7 @@ const axios = require('axios') const bodyParser = require('body-parser') function assignDefaults (strategy, defaults) { - Object.assign(strategy, defaults, strategy) + Object.assign(strategy, Object.assign({}, defaults, strategy)) } function addAuthorize (strategy) { diff --git a/lib/module.js b/lib/module.js index 6bb6f70da..32111134c 100644 --- a/lib/module.js +++ b/lib/module.js @@ -114,16 +114,16 @@ function processStrategy (strategy, name, ctx) { strategy._provider = strategy._name } - // _scheme property - if (!strategy._scheme) { - strategy._scheme = strategy._name - } - // Apply provider if (ctx.providers[strategy._provider]) { ctx.providers[strategy._provider].call(this, strategy, ctx) } + // _scheme property + if (!strategy._scheme) { + strategy._scheme = strategy._name + } + // Resolve _scheme if (SCHEMES.includes(strategy._scheme)) { strategy._scheme = `./schemes/${strategy._scheme}.js`