Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

login via external window

  • Loading branch information...
commit 4bbbb1a02c6408d32f399f66f1c2797bb44bb313 1 parent 5cc0682
@Swizec authored
View
10 app.js
@@ -55,7 +55,7 @@ app.get("/twitter_login", function (req, res) {
settings.twitter.key,
settings.twitter.secret,
"1.0",
- "http://githubfriends.swizec.com/twitter_login/callback",
+ "http://githubfriends.swizec.com/twitter_login/callback?userid="+req.query.userid,
"HMAC-SHA1");
oa.getOAuthRequestToken(function(error, oauth_token, oauth_token_secret, results) {
if (error) {
@@ -65,7 +65,7 @@ app.get("/twitter_login", function (req, res) {
req.session.oauth_token = oauth_token;
req.session.oauth_token_secret = oauth_token_secret;
- res.redirect("https://api.twitter.com/oauth/authorize?oauth_token="+oauth_token);
+ res.redirect("https://api.twitter.com/oauth/authenticate?oauth_token="+oauth_token);
}
});
});
@@ -93,7 +93,11 @@ app.get('/twitter_login/callback', function (req, res) {
if (req.param('action') && req.param('action') != '') {
res.redirect(req.param('action'));
}else{
- res.redirect("/");
+ users[req.query.userid].now.logged_in();
+
+ res.render('finish_login', {
+ title: "Logged in"
+ });
}
}
});
View
BIN  public/images/sign-in-with-twitter-l.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
7 public/js/script.js
@@ -5,11 +5,16 @@ $(function(){
Friends.append(friends);
};
+ now.logged_in = function () {
+ console.log("LOGGED IN!");
+ };
+
now.ready(function(){
now.initiate(function (clientId) {
console.log("I am client "+clientId);
- $.getJSON('/friends', {user: clientId}, function () {});
+ $("#login-twitter").attr("href", "/twitter_login?userid="+clientId);
+ //$.getJSON('/friends', {user: clientId}, function () {});
});
});
});
View
3  views/finish_login.ejs
@@ -0,0 +1,3 @@
+
+<p>Logged in!</p>
+<p>This window should close itself now</p>
View
2  views/index.ejs
@@ -1,4 +1,6 @@
+<a href="#" target="_blank" id="login-twitter"><img src="/images/sign-in-with-twitter-l.png" /></a>
+
<div id="loader"></div>
<div id="loader-template" style="display: none">
Please sign in to comment.
Something went wrong with that request. Please try again.