diff --git a/lib/lastfm_strategy.js b/lib/lastfm_strategy.js index f949b95..79781e8 100644 --- a/lib/lastfm_strategy.js +++ b/lib/lastfm_strategy.js @@ -15,7 +15,6 @@ function LastfmStrategy(options, verify){ options = options || {}; if (!options.api_key && !options.clientID) { throw new TypeError('LastfmStrategy requires a clientID obtained from http://www.last.fm/api/account/create'); } if (!options.secret && !options.clientSecret) { throw new TypeError('LastfmStrategy requires a clientSecret obtained from http://www.last.fm/api/account/create'); } - if (!options.callback_url && !options.callbackURL) { throw new TypeError('LastfmStrategy requires a callbackURL option'); } if (!verify || typeof(verify) != 'function') { throw new TypeError('LastfmStrategy requires verify callback function'); } @@ -37,7 +36,11 @@ function LastfmStrategy(options, verify){ LastfmStrategy.prototype.authenticate = function(request, options){ var self = this; - var authUrl = self.getAuthenticationUrl({cb:self.callbackURL}); + var callbackURL = options.callback_url || options.callbackURL || self.callbackURL; + + if (!callbackURL) throw new TypeError('LastfmStrategy requires a callbackURL option'); + + var authUrl = self.getAuthenticationUrl({cb:callbackURL}); if (request.query && request.query.token){ @@ -80,7 +83,7 @@ LastfmStrategy.prototype.getAuthenticationUrl = function(param) { if (params.token) { urlParts.query.token = params.token; } - var rtn = `${url.format(urlParts)}&cb=${this.callbackURL}`; + var rtn = `${url.format(urlParts)}&cb=${param.cb}`; return rtn ; };