mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
[FIX] AuthCoreProvider checkServer bug fixes
This commit is contained in:
parent
9fe1fc4f23
commit
8ea134dc27
3 changed files with 17 additions and 10 deletions
|
@ -234,7 +234,8 @@ public CheckServerReport checkServer(Client client, String username, String serv
|
|||
if (client.auth == null) return null;
|
||||
if (client.auth.isUseCore()) {
|
||||
User user = client.auth.core.checkServer(client, username, serverID);
|
||||
return user == null ? null : CheckServerReport.ofUser(user, getPlayerProfile(user));
|
||||
if (user == null) return null;
|
||||
else return CheckServerReport.ofUser(user, getPlayerProfile(client.auth, user));
|
||||
} else {
|
||||
UUID uuid = client.auth.handler.checkServer(username, serverID);
|
||||
return uuid == null ? null : CheckServerReport.ofUUID(uuid, getPlayerProfile(client.auth, uuid));
|
||||
|
@ -255,7 +256,7 @@ public PlayerProfile getPlayerProfile(Client client) {
|
|||
PlayerProfile playerProfile;
|
||||
if (client.useOAuth) {
|
||||
User user = client.getUser();
|
||||
playerProfile = getPlayerProfile(user);
|
||||
playerProfile = getPlayerProfile(client.auth, user);
|
||||
if (playerProfile != null) return playerProfile;
|
||||
}
|
||||
if (client.auth.textureProvider != null) {
|
||||
|
@ -273,7 +274,7 @@ public PlayerProfile getPlayerProfile(AuthProviderPair pair, String username, Cl
|
|||
UUID uuid = null;
|
||||
if (pair.isUseCore()) {
|
||||
User user = pair.core.getUserByUsername(username);
|
||||
PlayerProfile playerProfile = getPlayerProfile(user);
|
||||
PlayerProfile playerProfile = getPlayerProfile(pair, user);
|
||||
uuid = user.getUUID();
|
||||
if (playerProfile != null) return playerProfile;
|
||||
} else {
|
||||
|
@ -300,7 +301,7 @@ public PlayerProfile getPlayerProfile(AuthProviderPair pair, UUID uuid, ClientPr
|
|||
String username = null;
|
||||
if (pair.isUseCore()) {
|
||||
User user = pair.core.getUserByUUID(uuid);
|
||||
PlayerProfile playerProfile = getPlayerProfile(user);
|
||||
PlayerProfile playerProfile = getPlayerProfile(pair, user);
|
||||
username = user.getUsername();
|
||||
if (playerProfile != null) return playerProfile;
|
||||
} else {
|
||||
|
@ -319,11 +320,11 @@ public PlayerProfile getPlayerProfile(AuthProviderPair pair, UUID uuid, ClientPr
|
|||
return new PlayerProfile(uuid, username, null, null);
|
||||
}
|
||||
|
||||
public PlayerProfile getPlayerProfile(User user) {
|
||||
public PlayerProfile getPlayerProfile(AuthProviderPair pair, User user) {
|
||||
if (user instanceof UserSupportTextures) {
|
||||
return new PlayerProfile(user.getUUID(), user.getUsername(), ((UserSupportTextures) user).getSkinTexture(), ((UserSupportTextures) user).getCloakTexture());
|
||||
}
|
||||
return null;
|
||||
return getPlayerProfile(user.getUUID(), user.getUsername(), "", pair.textureProvider);
|
||||
}
|
||||
|
||||
private PlayerProfile getPlayerProfile(UUID uuid, String username, String client, TextureProvider textureProvider) {
|
||||
|
|
|
@ -34,13 +34,13 @@ public void execute(ChannelHandlerContext ctx, Client pClient) {
|
|||
if (report != null) {
|
||||
result.playerProfile = report.playerProfile;
|
||||
result.uuid = report.uuid;
|
||||
logger.debug("checkServer: {} uuid: {} serverID: {}", result.playerProfile.username, result.uuid, serverID);
|
||||
logger.debug("checkServer: {} uuid: {} serverID: {}", result.playerProfile == null ? null : result.playerProfile.username, result.uuid, serverID);
|
||||
}
|
||||
} catch (AuthException | HookException e) {
|
||||
sendError(e.getMessage());
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
logger.error("Internal authHandler error", e);
|
||||
sendError("Internal authHandler error");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -140,13 +140,19 @@ public void run(String... args) throws Throwable {
|
|||
if (config.logFile != null) LogHelper.addOutput(IOHelper.newWriter(Paths.get(config.logFile), true));
|
||||
{
|
||||
if (config.saveSession) {
|
||||
boolean needRestore = false;
|
||||
if (config.oauth != null) {
|
||||
Request.setOAuth(config.auth_id, config.oauth, config.oauthExpireTime);
|
||||
} else {
|
||||
needRestore = true;
|
||||
} else if (config.session != null) {
|
||||
Request.setSession(config.session);
|
||||
needRestore = true;
|
||||
} else {
|
||||
auth();
|
||||
}
|
||||
try {
|
||||
Request.restore();
|
||||
if (needRestore)
|
||||
Request.restore();
|
||||
} catch (Exception e) {
|
||||
LogHelper.error(e);
|
||||
auth();
|
||||
|
|
Loading…
Reference in a new issue