Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow providers params to be overloaded from nuxt.config.js #77

Merged
merged 1 commit into from
Mar 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion examples/demo/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion lib/auth/providers/_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should we move this line after provider?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise when _scheme is not defined in nuxt.config.js for a strategy, it is defaulted to the strategy._name before provider default params are assigned, resulting into provider._scheme value not being applied (since it's supposed to be a default value).
Since strategy._name usually does not refer to an existing scheme, it breaks the module.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for provided reasons. Seems reasonable :)

if (!strategy._scheme) {
strategy._scheme = strategy._name
}

// Resolve _scheme
if (SCHEMES.includes(strategy._scheme)) {
strategy._scheme = `./schemes/${strategy._scheme}.js`
Expand Down