diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/HttpAuthCoreProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/HttpAuthCoreProvider.java index 8c3b0402..c4539c03 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/HttpAuthCoreProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/HttpAuthCoreProvider.java @@ -252,8 +252,11 @@ public static class HttpUser implements User, UserSupportTextures, UserSupportPr private String serverId; private String accessToken; private ClientPermissions permissions; + @Deprecated private Texture skin; + @Deprecated private Texture cloak; + private Map assets; private Map properties; public HttpUser() { @@ -288,6 +291,16 @@ public HttpUser(String username, UUID uuid, String serverId, String accessToken, this.properties = properties; } + public HttpUser(String username, UUID uuid, String serverId, String accessToken, ClientPermissions permissions, Map assets, Map properties) { + this.username = username; + this.uuid = uuid; + this.serverId = serverId; + this.accessToken = accessToken; + this.permissions = permissions; + this.assets = assets; + this.properties = properties; + } + @Override public String getUsername() { return username; @@ -315,12 +328,32 @@ public ClientPermissions getPermissions() { @Override public Texture getSkinTexture() { - return skin; + if(assets == null) { + return skin; + } + return assets.get("SKIN"); } @Override public Texture getCloakTexture() { - return cloak; + if(assets == null) { + return cloak; + } + return assets.get("CAPE"); + } + + public Map getAssets() { + if(assets == null) { + Map map = new HashMap<>(); + if(skin != null) { + map.put("SKIN", skin); + } + if(cloak != null) { + map.put("CAPE", cloak); + } + return map; + } + return assets; } @Override diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/PostgresSQLCoreProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/PostgresSQLCoreProvider.java index e1f99ac9..86233d6b 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/PostgresSQLCoreProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/PostgresSQLCoreProvider.java @@ -83,11 +83,11 @@ public User getUserByLogin(String login) { public UserSession getUserSessionByOAuthAccessToken(String accessToken) throws OAuthAccessTokenExpired { try { var info = LegacySessionHelper.getJwtInfoFromAccessToken(accessToken, server.keyAgreementManager.ecdsaPublicKey); - var user = (MySQLCoreProvider.MySQLUser) getUserByUUID(info.uuid()); + var user = (PostgresSQLUser) getUserByUUID(info.uuid()); if(user == null) { return null; } - return new MySQLCoreProvider.MySQLUserSession(user); + return new PostgresSQLCoreProvider.MySQLUserSession(user); } catch (ExpiredJwtException e) { throw new OAuthAccessTokenExpired(); } catch (JwtException e) { @@ -103,7 +103,7 @@ public AuthManager.AuthReport refreshAccessToken(String refreshToken, AuthRespon } String username = parts[0]; String token = parts[1]; - var user = (MySQLCoreProvider.MySQLUser) getUserByUsername(username); + var user = (PostgresSQLUser) getUserByUsername(username); if(user == null || user.password == null) { return null; } @@ -112,7 +112,7 @@ public AuthManager.AuthReport refreshAccessToken(String refreshToken, AuthRespon return null; } var accessToken = LegacySessionHelper.makeAccessJwtTokenFromString(user, LocalDateTime.now().plusSeconds(expireSeconds), server.keyAgreementManager.ecdsaPrivateKey); - return new AuthManager.AuthReport(null, accessToken, refreshToken, expireSeconds * 1000L, new MySQLCoreProvider.MySQLUserSession(user)); + return new AuthManager.AuthReport(null, accessToken, refreshToken, expireSeconds * 1000L, new PostgresSQLCoreProvider.MySQLUserSession(user)); } @Override