diff --git a/app.js b/app.js index da18791..de3ec56 100644 --- a/app.js +++ b/app.js @@ -93,11 +93,12 @@ app.get('/twitter_login/callback', function (req, res) { if (req.param('action') && req.param('action') != '') { res.redirect(req.param('action')); }else{ - users[req.query.userid].now.logged_in(); + try { + users[req.query.userid].now.logged_in(); + }catch (e) { + } - res.render('finish_login', { - title: "Logged in" - }); + res.end("Logged in, window should close itself"); } } }); diff --git a/public/js/script.js b/public/js/script.js index b185672..5169f99 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -6,15 +6,26 @@ $(function(){ }; now.logged_in = function () { - console.log("LOGGED IN!"); + window.PopUp.close(); + + $.getJSON('/friends', {user: window.clientId}, function () {}); }; now.ready(function(){ now.initiate(function (clientId) { + window.clientId = clientId; console.log("I am client "+clientId); - $("#login-twitter").attr("href", "/twitter_login?userid="+clientId); - //$.getJSON('/friends', {user: clientId}, function () {}); + var url = "/twitter_login?userid="+clientId; + + $("#login-twitter").attr("href", url) + .click(function (event) { + event.preventDefault(); + + window.PopUp = window.open(url, + 'Login', + 'width=600,height=400'); + }); }); }); });