From 17bce5dff068be2eb5bc68fdf85a98c181425776 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 22 Aug 2020 23:21:21 +0700 Subject: [PATCH] [FIX] Username case --- .../launchserver/auth/handler/HibernateAuthHandler.java | 4 +++- .../launchserver/auth/provider/HibernateAuthProvider.java | 2 +- .../launchserver/socket/response/auth/AuthResponse.java | 4 ++-- build.gradle | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/handler/HibernateAuthHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/handler/HibernateAuthHandler.java index 021eb3c3..c7a3a3fa 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/handler/HibernateAuthHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/handler/HibernateAuthHandler.java @@ -1,6 +1,7 @@ package pro.gravit.launchserver.auth.handler; import pro.gravit.launchserver.dao.User; +import pro.gravit.utils.helper.LogHelper; import java.util.UUID; @@ -9,7 +10,7 @@ public class HibernateAuthHandler extends CachedAuthHandler { protected Entry fetchEntry(String username) { User user = srv.config.dao.userDAO.findByUsername(username); if (user == null) return null; - return new Entry(user.getUuid(), username, user.getAccessToken(), user.getServerID()); + return new Entry(user.getUuid(), user.getUsername(), user.getAccessToken(), user.getServerID()); } @Override @@ -22,6 +23,7 @@ protected Entry fetchEntry(UUID uuid) { @Override protected boolean updateAuth(UUID uuid, String username, String accessToken) { User user = srv.config.dao.userDAO.findByUUID(uuid); + LogHelper.debug("UpdateAuth: %s: %s", uuid == null ? "null" : uuid.toString(), user == null ? "null" : user.getUsername()); user.setAccessToken(accessToken); srv.config.dao.userDAO.update(user); return true; diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/HibernateAuthProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/HibernateAuthProvider.java index ef68d6ae..05cd046c 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/HibernateAuthProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/HibernateAuthProvider.java @@ -26,7 +26,7 @@ public AuthProviderResult auth(String login, AuthRequest.AuthPasswordInterface p if (user == null) throw new AuthException("Username incorrect"); else throw new AuthException("Username or password incorrect"); } - return new AuthProviderDAOResult(login, SecurityHelper.randomStringToken(), user.getPermissions(), user); + return new AuthProviderDAOResult(user.getUsername(), SecurityHelper.randomStringToken(), user.getPermissions(), user); } @Override diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/AuthResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/AuthResponse.java index 5d574a20..0f09af7c 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/AuthResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/AuthResponse.java @@ -81,8 +81,8 @@ public void execute(ChannelHandlerContext ctx, Client clientData) throws Excepti clientData.permissions = aresult.permissions; clientData.auth_id = auth_id; clientData.updateAuth(server); - if (result.playerProfile != null) - clientData.username = result.playerProfile.username; + if (aresult.username != null) + clientData.username = aresult.username; else clientData.username = login; if(aresult instanceof AuthProviderDAOResult) diff --git a/build.gradle b/build.gradle index d04df198..849539f4 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ id 'org.openjfx.javafxplugin' version '0.0.8' apply false } group = 'pro.gravit.launcher' -version = '5.1.7' +version = '5.1.8-SNAPSHOT' apply from: 'props.gradle'