diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/AuthProviderDAOResult.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/AuthProviderDAOResult.java new file mode 100644 index 00000000..debb953d --- /dev/null +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/AuthProviderDAOResult.java @@ -0,0 +1,21 @@ +package pro.gravit.launchserver.auth.provider; + +import pro.gravit.launcher.ClientPermissions; +import pro.gravit.launchserver.dao.User; + +public class AuthProviderDAOResult extends AuthProviderResult { + public User daoObject; + + public AuthProviderDAOResult(String username, String accessToken) { + super(username, accessToken); + } + + public AuthProviderDAOResult(String username, String accessToken, ClientPermissions permissions) { + super(username, accessToken, permissions); + } + + public AuthProviderDAOResult(String username, String accessToken, ClientPermissions permissions, User daoObject) { + super(username, accessToken, permissions); + this.daoObject = daoObject; + } +} 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 8ce22cef..ef68d6ae 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 AuthProviderResult(login, SecurityHelper.randomStringToken(), user.getPermissions()); + return new AuthProviderDAOResult(login, 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 520d6675..15667812 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 @@ -8,6 +8,7 @@ import pro.gravit.launchserver.auth.AuthException; import pro.gravit.launchserver.auth.AuthProviderPair; import pro.gravit.launchserver.auth.provider.AuthProvider; +import pro.gravit.launchserver.auth.provider.AuthProviderDAOResult; import pro.gravit.launchserver.auth.provider.AuthProviderResult; import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.response.SimpleResponse; @@ -84,6 +85,10 @@ public void execute(ChannelHandlerContext ctx, Client clientData) throws Excepti clientData.username = result.playerProfile.username; else clientData.username = login; + if(aresult instanceof AuthProviderDAOResult) + { + clientData.daoObject = ((AuthProviderDAOResult) aresult).daoObject; + } result.accessToken = aresult.accessToken; result.permissions = clientData.permissions; if (getSession) {