Fix issue where certain providers do not return the 'provider' field

Not all passport providers return `profile.provider` (notably OpenID). This causes an error when trying to authenticate against those providers i.e. `passport-google`.

Fixed the problem by using `query.provider` as a backup source when `profile.provider` is `undefined`.

Additionally, removed the unused `config` variable declaration.
Done.

 

From: Kasper Isager [mailto:notifications@github.com] 
Sent: Friday, September 05, 2014 8:41 AM
To: kasperisager/sails-generate-auth
Cc: Ken Benjamin
Subject: Re: [sails-generate-auth] Fix issue where certain providers do not return the 'provider' field (#73)

 

In templates/api/services/passport.js:

> @@ -88,8 +98,8 @@ passport.connect = function (req, query, profile, next) {
>    }
>  
>    Passport.findOne({
> -    provider   : profile.provider
> -  , identifier : query.identifier.toString()
> +      provider: provider,
> +    identifier : query.identifier.toString()

Could you convert the tab to spaces and use comma-first? Consistency is key   <https://assets-cdn.github.com/images/icons/emoji/unicode/1f44d.png> 

—
Reply to this email directly or view it on GitHub <https://github.com/kasperisager/sails-generate-auth/pull/73/files#r17158744> .  <https://github.com/notifications/beacon/1645415__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcyNTUxODQzNSwiZGF0YSI6eyJpZCI6NDA1NDMyMTN9fQ==--93a8787cde6237f2ae712d82496fcd569bf3d7f4.gif>