move common code from oauth2 providers up into _requestHandler

This commit is contained in:
Mike Bannister
2012-08-02 03:00:32 -04:00
committed by Nick Martin
parent 768af064ba
commit 380910d72f
5 changed files with 15 additions and 31 deletions

View File

@@ -5,15 +5,6 @@
};
Meteor.accounts.oauth.registerService('facebook', {version: 2}, function(query) {
if (query.error) {
// The user didn't authorize access
return null;
}
if (!Meteor.accounts.facebook._appId || !Meteor.accounts.facebook._appUrl)
throw new Meteor.accounts.ConfigError("Need to call Meteor.accounts.facebook.config first");
if (!Meteor.accounts.facebook._secret)
throw new Meteor.accounts.ConfigError("Need to call Meteor.accounts.facebook.setSecret first");
var accessToken = getAccessToken(query);
var identity = getIdentity(accessToken);

View File

@@ -5,15 +5,6 @@
};
Meteor.accounts.oauth.registerService('google', {version: 2}, function(query) {
if (query.error) {
// The user didn't authorize access
return null;
}
if (!Meteor.accounts.google._appId || !Meteor.accounts.google._appUrl)
throw new Meteor.accounts.ConfigError("Need to call Meteor.accounts.google.config first");
if (!Meteor.accounts.google._secret)
throw new Meteor.accounts.ConfigError("Need to call Meteor.accounts.google.setSecret first");
var accessToken = getAccessToken(query);
var identity = getIdentity(accessToken);

View File

@@ -23,16 +23,16 @@
return;
}
// Make sure we prepare the login results before returning.
// This way the subsequent call to the `login` method will be
// immediate.
// Make sure we're configured
if (!Meteor.accounts[serviceName]._appId || !Meteor.accounts[serviceName]._appUrl)
throw new Meteor.accounts.ConfigError("Need to call Meteor.accounts." + serviceName + ".config first");
if (!Meteor.accounts[serviceName]._secret)
throw new Meteor.accounts.ConfigError("Need to call Meteor.accounts." + serviceName + ".setSecret first");
// Make sure we prepare the login results before returning.
// This way the subsequent call to the `login` method will be
// immediate.
var config = Meteor.accounts[serviceName];
var oauth = new OAuth1(config);

View File

@@ -24,6 +24,17 @@
return;
}
// Make sure we're configured
if (!Meteor.accounts[serviceName]._appId || !Meteor.accounts[serviceName]._appUrl)
throw new Meteor.accounts.ConfigError("Need to call Meteor.accounts." + serviceName + ".config first");
if (!Meteor.accounts[serviceName]._secret)
throw new Meteor.accounts.ConfigError("Need to call Meteor.accounts." + serviceName + ".setSecret first");
if (req.query.error) {
// The user didn't authorize access
return null;
}
// Make sure we prepare the login results before returning.
// This way the subsequent call to the `login` method will be
// immediate.

View File

@@ -5,15 +5,6 @@
};
Meteor.accounts.oauth.registerService('weibo', {version: 2}, function(query) {
if (query.error) {
// The user didn't authorize access
return null;
}
if (!Meteor.accounts.weibo._appId || !Meteor.accounts.weibo._appUrl)
throw new Meteor.accounts.ConfigError("Need to call Meteor.accounts.weibo.config first");
if (!Meteor.accounts.weibo._secret)
throw new Meteor.accounts.ConfigError("Need to call Meteor.accounts.weibo.setSecret first");
var accessToken = getAccessToken(query);
var identity = getIdentity(accessToken.access_token, parseInt(accessToken.uid, 10));