mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
moved common server side oauth setup code to accounts-oauth-helpers
This commit is contained in:
committed by
Nick Martin
parent
2acd9e17e3
commit
19f043583d
@@ -3,26 +3,7 @@
|
||||
|
||||
Meteor.accounts.oauth1._services = {};
|
||||
|
||||
// Listen to calls to `login` with an oauth option set
|
||||
Meteor.accounts.registerLoginHandler(function (options) {
|
||||
if (!options.oauth || options.oauth.version !== 1)
|
||||
return undefined; // don't handle
|
||||
|
||||
var result = Meteor.accounts.oauth1._loginResultForState[options.oauth.state];
|
||||
if (result === undefined) // not using `!result` since can be null
|
||||
// We weren't notified of the user authorizing the login.
|
||||
return null;
|
||||
else
|
||||
return result;
|
||||
});
|
||||
|
||||
// When we get an incoming OAuth http request we complete the oauth
|
||||
// handshake, account and token setup before responding. The
|
||||
// results are stored in this map which is then read when the login
|
||||
// method is called. Maps state --> return value of `login`
|
||||
//
|
||||
// XXX we should periodically clear old entries
|
||||
Meteor.accounts.oauth1._loginResultForState = {};
|
||||
Meteor.accounts.oauth._setup({oauthVersion: 1});
|
||||
|
||||
// connect middleware
|
||||
Meteor.accounts.oauth1._handleRequest = function (req, res, next) {
|
||||
|
||||
@@ -3,33 +3,11 @@
|
||||
|
||||
Meteor.accounts.oauth2._services = {};
|
||||
|
||||
// Listen to calls to `login` with an oauth option set
|
||||
Meteor.accounts.registerLoginHandler(function (options) {
|
||||
if (!options.oauth || options.oauth.version !== 2)
|
||||
return undefined; // don't handle
|
||||
|
||||
var result = Meteor.accounts.oauth2._loginResultForState[options.oauth.state];
|
||||
if (result === undefined) // not using `!result` since can be null
|
||||
// We weren't notified of the user authorizing the login.
|
||||
return null;
|
||||
else if (result instanceof Error)
|
||||
// We tried to login, but there was a fatal error. Report it back
|
||||
// to the user.
|
||||
throw result;
|
||||
else
|
||||
return result;
|
||||
});
|
||||
|
||||
// When we get an incoming OAuth http request we complete the oauth
|
||||
// handshake, account and token setup before responding. The
|
||||
// results are stored in this map which is then read when the login
|
||||
// method is called. Maps state --> return value of `login`
|
||||
//
|
||||
// XXX we should periodically clear old entries
|
||||
Meteor.accounts.oauth2._loginResultForState = {};
|
||||
Meteor.accounts.oauth._setup({oauthVersion: 2});
|
||||
|
||||
// connect middleware
|
||||
Meteor.accounts.oauth2._handleRequest = function (req, res, next) {
|
||||
|
||||
// req.url will be "/_oauth/<service name>?<action>"
|
||||
// NOTE: query param is mandatory.
|
||||
var barePath = req.url.substring(0, req.url.indexOf('?'));
|
||||
|
||||
Reference in New Issue
Block a user