Files
meteor/packages/accounts-github/github_client.js
Alex Notov 28b42e924e Removed linkedin package from this PR
Login services should be defined from within their packages

Corresponding login service assets (images and css should be in their respective packages not inside of accounts-ui-unstyled)

Conflicts:
	packages/accounts-linkedin/linkedin_client.js
	packages/accounts-linkedin/package.js
	packages/accounts-ui-unstyled/login_buttons.js
	packages/accounts-ui-unstyled/login_buttons_images.css
2012-12-26 23:04:14 -08:00

31 lines
973 B
JavaScript

(function () {
Meteor.loginWithGithub = function (options, callback) {
// support both (options, callback) and (callback).
if (!callback && typeof options === 'function') {
callback = options;
options = {};
}
var config = Accounts.loginServiceConfiguration.findOne({service: 'github'});
if (!config) {
callback && callback(new Accounts.ConfigError("Service not configured"));
return;
}
var state = Meteor.uuid();
var scope = (options && options.requestPermissions) || [];
var flatScope = _.map(scope, encodeURIComponent).join('+');
var loginUrl =
'https://github.com/login/oauth/authorize' +
'?client_id=' + config.clientId +
'&scope=' + flatScope +
'&redirect_uri=' + Meteor.absoluteUrl('_oauth/github?close') +
'&state=' + state;
Accounts.oauth.initiateLogin(state, loginUrl, callback, {width: 900, height: 450});
};
Accounts._loginButtons.loginServices.push('github');
}) ();