Use query parameter for after-redirect action instead of pathname.

Allows meteorid to be like all the other oauth packages. Revert the big hack for
putting the after-redirect action in the pathname.
This commit is contained in:
Emily Stark
2013-12-06 16:37:51 -08:00
parent e46264d283
commit 91c995a243
3 changed files with 5 additions and 28 deletions

View File

@@ -21,7 +21,7 @@ MeteorId.requestCredential = function (credentialRequestCompleteCallback) {
"state=" + credentialToken +
"&response_type=code&" +
"client_id=" + config.clientId +
"&redirect_uri=" + Meteor.absoluteUrl("_oauth/meteorId/close");
"&redirect_uri=" + Meteor.absoluteUrl("_oauth/meteorId?close");
Oauth.showPopup(
loginUrl,

View File

@@ -44,7 +44,7 @@ var getTokens = function (query) {
code: query.code,
client_id: config.clientId,
client_secret: config.secret,
redirect_uri: Meteor.absoluteUrl("_oauth/meteorId/close")
redirect_uri: Meteor.absoluteUrl("_oauth/meteorId?close")
}
}
);

View File

@@ -132,36 +132,13 @@ middleware = function (req, res, next) {
OauthTest.middleware = middleware;
// Handle /_oauth/* paths and extract the service name. Hack: If we find a
// <service name>+<action> path, extract the action and put it into
// req.query. These paths are used for services that don't allow query
// parameters in redirect_uris.
// Handle /_oauth/* paths and extract the service name.
//
// @returns {String|null} e.g. "facebook", or null if this isn't an
// oauth request
var oauthServiceName = function (req) {
// req.url will be "/_oauth/<service name>?<action>", or for services that
// don't support query parameters in req.url (*cough*meteoraccounts*cough*),
// "<service name>/<action>".
var barePath;
var url = req.url;
var questionIndex = url.indexOf("?");
var slashIndex = url.indexOf("/",
url.indexOf("/_oauth/") + "/_oauth/".length);
if (slashIndex !== -1 &&
(questionIndex === -1 || questionIndex > slashIndex)) {
barePath = url.substring(0, slashIndex);
var action = url.substring(
slashIndex + 1,
questionIndex === -1 ? undefined : questionIndex
);
if (action)
req.query[action] = true;
} else if (questionIndex !== -1) {
barePath = url.substring(0, questionIndex);
} else {
barePath = url;
}
// req.url will be "/_oauth/<service name>?<action>"
var barePath = req.url.substring(0, req.url.indexOf('?'));
var splitPath = barePath.split('/');
// Any non-oauth request will continue down the default