mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
move common code from oauth2 providers up into _requestHandler
This commit is contained in:
committed by
Nick Martin
parent
768af064ba
commit
380910d72f
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user