Navigation Menu

Skip to content

Commit

Permalink
login via a popup
Browse files Browse the repository at this point in the history
  • Loading branch information
Swizec committed Jun 6, 2011
1 parent 4bbbb1a commit 583ecdb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
9 changes: 5 additions & 4 deletions app.js
Expand Up @@ -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");
}
}
});
Expand Down
17 changes: 14 additions & 3 deletions public/js/script.js
Expand Up @@ -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');
});
});
});
});
Expand Down

0 comments on commit 583ecdb

Please sign in to comment.