Applied changes

This commit is contained in:
Norbi Peti 2017-06-30 18:21:03 +02:00
parent 812f70f5e1
commit 2aa02a34cb
2 changed files with 3 additions and 3 deletions

View file

@ -17,6 +17,6 @@ public class WebUser extends ChromaGamerBase {
} }
public PlayerData<UUID> sessionID() { public PlayerData<UUID> sessionID() {
return data(); return data(null);
} }
} }

View file

@ -78,7 +78,7 @@ public class IOHelper {
user.sessionID().set(UUID.randomUUID()); user.sessionID().set(UUID.randomUUID());
user.save(); user.save();
new Cookies(2).add(new Cookie("user_id", user.getUUID() + "")) new Cookies(2).add(new Cookie("user_id", user.getUUID() + ""))
.add(new Cookie("session_id", user.sessionID().getOrDefault(null).toString())).SendHeaders(exchange); .add(new Cookie("session_id", user.sessionID().get().toString())).SendHeaders(exchange);
Bukkit.getLogger().fine("Logged in user."); Bukkit.getLogger().fine("Logged in user.");
} }
@ -139,7 +139,7 @@ public class IOHelper {
return null; return null;
WebUser user = ChromaGamerBase.getUser(cookies.get("user_id").getValue(), WebUser.class); WebUser user = ChromaGamerBase.getUser(cookies.get("user_id").getValue(), WebUser.class);
if (user != null && cookies.get("session_id") != null if (user != null && cookies.get("session_id") != null
&& cookies.get("session_id").getValue().equals(user.sessionID().getOrDefault(null))) { && cookies.get("session_id").getValue().equals(user.sessionID().get())) {
if (cookies.getExpireTimeParsed().minusYears(1).isBefore(ZonedDateTime.now(ZoneId.of("GMT")))) if (cookies.getExpireTimeParsed().minusYears(1).isBefore(ZonedDateTime.now(ZoneId.of("GMT"))))
LoginUser(exchange, user); LoginUser(exchange, user);
return user; return user;