mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
UIWebView which aren't able to use the preferred "popup" login flow. See the specs for details: https://meteor.hackpad.com/OAuth-redirect-flow-spec-PeziTcaNPDP https://meteor.hackpad.com/OAuth-redirect-flow-part-II-vswwUKP4vXe I extracted code to construct a URL from the `http` package into a new `url` utility package. The new package has no public API, it simply has the original URL construction functions that were in `http` and makes them available to oauth. Fixes the Meetup account login, as Meetup now requires using "https://api.meetup.com/2/members" instead of "https://secure.meetup.com/2/members". The `?close` parameter for the redirect URI is now not needed or used. For backwards compatibility the `?close` parameter is included if the login service configuration doesn't include the `loginStyle` field (indicating it was created using old code).
48 lines
1.6 KiB
JavaScript
48 lines
1.6 KiB
JavaScript
// Request Meteor developer account credentials for the user
|
|
// @param credentialRequestCompleteCallback {Function} Callback function to call on
|
|
// completion. Takes one argument, credentialToken on success, or Error on
|
|
// error.
|
|
var requestCredential = function (options, credentialRequestCompleteCallback) {
|
|
// support a callback without options
|
|
if (! credentialRequestCompleteCallback && typeof options === "function") {
|
|
credentialRequestCompleteCallback = options;
|
|
options = null;
|
|
}
|
|
|
|
var config = ServiceConfiguration.configurations.findOne({
|
|
service: 'meteor-developer'
|
|
});
|
|
if (!config) {
|
|
credentialRequestCompleteCallback &&
|
|
credentialRequestCompleteCallback(new ServiceConfiguration.ConfigError());
|
|
return;
|
|
}
|
|
|
|
var credentialToken = Random.secret();
|
|
|
|
var loginStyle = OAuth._loginStyle('facebook', config, options);
|
|
|
|
var loginUrl =
|
|
MeteorDeveloperAccounts._server +
|
|
"/oauth2/authorize?" +
|
|
"state=" + OAuth._stateParam(loginStyle, credentialToken) +
|
|
"&response_type=code&" +
|
|
"client_id=" + config.clientId;
|
|
|
|
if (options && options.userEmail)
|
|
loginUrl += '&user_email=' + encodeURIComponent(options.userEmail);
|
|
|
|
loginUrl += "&redirect_uri=" + OAuth._redirectUri('meteor-developer', config);
|
|
|
|
OAuth.launchLogin({
|
|
loginService: "meteor-developer",
|
|
loginStyle: loginStyle,
|
|
loginUrl: loginUrl,
|
|
credentialRequestCompleteCallback: credentialRequestCompleteCallback,
|
|
credentialToken: credentialToken,
|
|
popupOptions: {width: 470, height: 420}
|
|
});
|
|
};
|
|
|
|
MeteorDeveloperAccounts.requestCredential = requestCredential;
|