aboutsummaryrefslogtreecommitdiff
path: root/src/java/com/juick/http/www/FacebookLogin.java
diff options
context:
space:
mode:
authorGravatar Ugnich Anton2013-07-21 23:36:07 +0700
committerGravatar Ugnich Anton2013-07-21 23:36:07 +0700
commitc37d78969da40f4238573bbee2c533c878ea3844 (patch)
tree02a592aa81ad7bfdffdf46b99527bd596a791580 /src/java/com/juick/http/www/FacebookLogin.java
parent3692155bcddc13886bbbc0fd89bb4a4e3a24c88d (diff)
Signup/Login bugfixes
Diffstat (limited to 'src/java/com/juick/http/www/FacebookLogin.java')
-rw-r--r--src/java/com/juick/http/www/FacebookLogin.java24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/java/com/juick/http/www/FacebookLogin.java b/src/java/com/juick/http/www/FacebookLogin.java
index 8933075b..7f233f04 100644
--- a/src/java/com/juick/http/www/FacebookLogin.java
+++ b/src/java/com/juick/http/www/FacebookLogin.java
@@ -52,7 +52,7 @@ public class FacebookLogin {
response.addCookie(c);
response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
- response.setHeader("Location", "https://www.facebook.com/dialog/oauth?client_id=" + FACEBOOK_APPID + "&redirect_uri=" + URLEncoder.encode(FACEBOOK_REDIRECT, "utf-8") + "&state=" + fbstate);
+ response.setHeader("Location", "https://www.facebook.com/dialog/oauth?scope=publish_stream&client_id=" + FACEBOOK_APPID + "&redirect_uri=" + URLEncoder.encode(FACEBOOK_REDIRECT, "utf-8") + "&state=" + fbstate);
return;
}
@@ -102,6 +102,9 @@ public class FacebookLogin {
int uid = getUIDbyFBID(sql, fbID);
if (uid > 0) {
+ if (!updateDB(sql, fbID, token, fbName, fbLink)) {
+ throw new Exception();
+ }
Cookie c = new Cookie("hash", UserQueries.getHashByUID(sql, uid));
c.setMaxAge(50 * 24 * 60 * 60);
response.addCookie(c);
@@ -159,4 +162,23 @@ public class FacebookLogin {
}
return ret;
}
+
+ private boolean updateDB(Connection sql, long fbID, String token, String fbName, String fbLink) {
+ boolean ret = false;
+ PreparedStatement stmt = null;
+ try {
+ stmt = sql.prepareStatement("UPDATE facebook SET access_token=?,fb_name=?,fb_link=? WHERE fb_id=?");
+ stmt.setString(1, token);
+ stmt.setString(2, fbName);
+ stmt.setString(3, fbLink);
+ stmt.setLong(4, fbID);
+ stmt.executeUpdate();
+ ret = true;
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(null, stmt);
+ }
+ return ret;
+ }
}