Skip to content

Commit

Permalink
Fixed login function to get the clientId
Browse files Browse the repository at this point in the history
  • Loading branch information
Paolo Scanferla committed May 8, 2014
1 parent 37a42e2 commit 7f7c919
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 37 deletions.
20 changes: 6 additions & 14 deletions demo/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
var options = {
host: "http://localhost:3000"
};
options.ddpOptions = {
endpoint: "ws://localhost:3000/websocket",
SocketConstructor: WebSocket,
debug: true
};
var Rocket = new Asteroid(options);
Rocket.on("connected", function () {
var ceres = new Asteroid("localhost:3000");
ceres.on("connected", function () {
console.log("Connected!");
});

window.onload = function () {
document.getElementById("fb").addEventListener("click", function () {
Rocket.loginWithFacebook()
ceres.loginWithFacebook()
.then(function (id) {
console.log(id);
})
Expand All @@ -22,17 +14,17 @@ window.onload = function () {
});
}, false);
document.getElementById("tw").addEventListener("click", function () {
Rocket.loginWithTwitter().then(function (id) {
ceres.loginWithTwitter().then(function (id) {
console.log(id);
});
}, false);
document.getElementById("gl").addEventListener("click", function () {
Rocket.loginWithGoogle().then(function (id) {
ceres.loginWithGoogle().then(function (id) {
console.log(id);
});
}, false);
document.getElementById("gh").addEventListener("click", function () {
Rocket.loginWithGithub().then(function (id) {
ceres.loginWithGithub().then(function (id) {
console.log(id);
});
}, false);
Expand Down
14 changes: 3 additions & 11 deletions dist/asteroid.js
Original file line number Diff line number Diff line change
Expand Up @@ -684,17 +684,9 @@ Asteroid.DumbDb = DumbDb;

Asteroid.prototype._getOauthClientId = function (serviceName) {
var loginConfigCollectionName = "meteor_accounts_loginServiceConfiguration";
var services = this.collections[loginConfigCollectionName].db.itemsArray;
var clientId = "";
services.forEach(function (service) {
if (service.service === serviceName) {
if (serviceName === "facebook") clientId = service.appId;
if (serviceName === "google") clientId = service.clientId;
if (serviceName === "github") clientId = service.clientId;
if (serviceName === "twitter") clientId = service.consumerKey;
}
});
return clientId;
var loginConfigCollection = this.collections[loginConfigCollectionName];
var service = loginConfigCollection.reactiveQuery({service: serviceName}).result[0];
return service.clientId;
};

Asteroid.prototype._initOauthLogin = function (service, credentialToken, loginUrl) {
Expand Down
Loading

0 comments on commit 7f7c919

Please sign in to comment.