Created
May 24, 2016 06:31
-
-
Save phund/955c84476681a16047b40e1ed526b4e3 to your computer and use it in GitHub Desktop.
mrt_accounts-facebook-cordova.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
////////////////////////////////////////////////////////////////////////// | |
// // | |
// This is a generated file. You can view the original // | |
// source in your browser if your browser supports source maps. // | |
// Source maps are supported by all recent versions of Chrome, Safari, // | |
// and Firefox, and by Internet Explorer 11. // | |
// // | |
////////////////////////////////////////////////////////////////////////// | |
(function () { | |
/* Imports */ | |
var Meteor = Package.meteor.Meteor; | |
var Accounts = Package['accounts-base'].Accounts; | |
var AccountsClient = Package['accounts-base'].AccountsClient; | |
var Facebook = Package.facebook.Facebook; | |
var ServiceConfiguration = Package['service-configuration'].ServiceConfiguration; | |
(function(){ | |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// // | |
// packages/mrt_accounts-facebook-cordova/packages/mrt_accounts-facebook-cordova.js // | |
// // | |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
// | |
(function () { // 1 | |
// 2 | |
///////////////////////////////////////////////////////////////////////////////////////////////////////// // 3 | |
// // // 4 | |
// packages/mrt:accounts-facebook-cordova/facebook.js // // 5 | |
// // // 6 | |
///////////////////////////////////////////////////////////////////////////////////////////////////////// // 7 | |
// // 8 | |
Accounts.oauth.registerService('facebook'); // 1 // 9 | |
// 2 // 10 | |
if (Meteor.isClient) { // 3 // 11 | |
// 4 // 12 | |
Meteor.loginWithFacebook = function(options, callback) { // 5 // 13 | |
// support a callback without options // 6 // 14 | |
if (! callback && typeof options === "function") { // 7 // 15 | |
callback = options; // 8 // 16 | |
options = null; // 9 // 17 | |
} // 10 | |
// 11 | |
var credentialRequestCompleteCallback = Accounts.oauth.credentialRequestCompleteHandler(callback); // 12 | |
// 13 | |
var fbLoginSuccess = function (data) { // 14 | |
data.cordova = true; // 15 | |
// 16 | |
Accounts.callLoginMethod({ // 17 | |
methodArguments: [data], // 18 | |
userCallback: callback // 19 | |
}); // 20 | |
} // 21 | |
// 22 | |
if (typeof facebookConnectPlugin != "undefined" && Meteor.settings) { // 23 | |
facebookConnectPlugin.getLoginStatus( // 24 | |
function (response) { // 25 | |
if (response.status != "connected") { // 26 | |
facebookConnectPlugin.login(Meteor.settings.public.facebook.permissions, // 27 | |
fbLoginSuccess, // 28 | |
function (error) { console.log("" + error) } // 29 | |
); // 30 | |
} else { // 31 | |
fbLoginSuccess(response); // 32 | |
} // 33 | |
}, // 34 | |
function (error) { console.log("" + error) } // 35 | |
); // 36 | |
} else { // 37 | |
Facebook.requestCredential(options, credentialRequestCompleteCallback); // 38 | |
} // 39 | |
}; // 40 | |
// 41 | |
} else { // 42 | |
// 43 | |
if (Meteor.settings && // 44 | |
Meteor.settings.facebook && // 45 | |
Meteor.settings.facebook.appId && // 46 | |
Meteor.settings.facebook.secret) { // 47 | |
// 48 | |
ServiceConfiguration.configurations.remove({ // 49 | |
service: "facebook" // 50 | |
}); // 51 | |
// 52 | |
ServiceConfiguration.configurations.insert({ // 53 | |
service: "facebook", // 54 | |
appId: Meteor.settings.facebook.appId, // 55 | |
secret: Meteor.settings.facebook.secret // 56 | |
}); // 57 | |
// 58 | |
Accounts.addAutopublishFields({ // 59 | |
// publish all fields including access token, which can legitimately // 60 | |
// be used from the client (if transmitted over ssl or on // 61 | |
// localhost). https://developers.facebook.com/docs/concepts/login/access-tokens-and-types/, // 62 | |
// "Sharing of Access Tokens" // 63 | |
forLoggedInUser: ['services.facebook'], // 64 | |
forOtherUsers: [ // 65 | |
// https://www.facebook.com/help/167709519956542 // 66 | |
'services.facebook.id', 'services.facebook.username', 'services.facebook.gender' // 67 | |
] // 68 | |
}); // 69 | |
// 70 | |
} else { // 71 | |
console.log("Meteor settings for accounts-facebook-cordova not configured correctly.") // 72 | |
} // 73 | |
} // 74 | |
// 75 | |
///////////////////////////////////////////////////////////////////////////////////////////////////////// // 84 | |
// 85 | |
}).call(this); // 86 | |
// 87 | |
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
}).call(this); | |
/* Exports */ | |
if (typeof Package === 'undefined') Package = {}; | |
Package['mrt:accounts-facebook-cordova'] = {}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment