aboutsummaryrefslogtreecommitdiff
path: root/src/java/com/juick/http/www/Utils.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/com/juick/http/www/Utils.java')
-rw-r--r--src/java/com/juick/http/www/Utils.java21
1 files changed, 6 insertions, 15 deletions
diff --git a/src/java/com/juick/http/www/Utils.java b/src/java/com/juick/http/www/Utils.java
index b2d9a999..35b918b8 100644
--- a/src/java/com/juick/http/www/Utils.java
+++ b/src/java/com/juick/http/www/Utils.java
@@ -48,28 +48,19 @@ public class Utils {
return null;
}
- public static com.juick.User getVisitorUser(Connection sql, HttpServletRequest request) {
+ public static com.juick.User getVisitorUser(Connection sql, HttpServletRequest request, HttpServletResponse response) {
String hash = getCookie(request, "hash");
if (hash != null) {
- return com.juick.server.UserQueries.getUserByHash(sql, hash);
+ com.juick.User visitor = com.juick.server.UserQueries.getUserByHash(sql, hash);
+ if (response != null && visitor != null) {
+ response.setHeader("X-Username", visitor.UName);
+ }
+ return visitor;
} else {
return null;
}
}
- public static int getVisitorUID(Connection sql, HttpServletRequest request) {
- Cookie cookies[] = request.getCookies();
- if (cookies != null) {
- for (int i = 0; i < cookies.length; i++) {
- if (cookies[i].getName().equals("hash")) {
- String hash = cookies[i].getValue();
- return com.juick.server.UserQueries.getUIDbyHash(sql, hash);
- }
- }
- }
- return 0;
- }
-
public static void sendTemporaryRedirect(HttpServletResponse response, String location) {
response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
response.setHeader("Location", location);