mirror of
https://github.com/SKCraft/Launcher.git
synced 2024-11-30 13:13:58 +01:00
Use cached avatar in MicrosoftLoginService
This commit is contained in:
parent
21a108f796
commit
b189173b34
@ -38,7 +38,7 @@ public class MicrosoftLoginService implements LoginService {
|
|||||||
form.add("code", code);
|
form.add("code", code);
|
||||||
});
|
});
|
||||||
|
|
||||||
Profile session = performLogin(response.getAccessToken());
|
Profile session = performLogin(response.getAccessToken(), null);
|
||||||
session.setRefreshToken(response.getRefreshToken());
|
session.setRefreshToken(response.getRefreshToken());
|
||||||
|
|
||||||
return session;
|
return session;
|
||||||
@ -52,7 +52,7 @@ public class MicrosoftLoginService implements LoginService {
|
|||||||
form.add("refresh_token", savedSession.getRefreshToken());
|
form.add("refresh_token", savedSession.getRefreshToken());
|
||||||
});
|
});
|
||||||
|
|
||||||
Profile session = performLogin(response.getAccessToken());
|
Profile session = performLogin(response.getAccessToken(), savedSession);
|
||||||
session.setRefreshToken(response.getRefreshToken());
|
session.setRefreshToken(response.getRefreshToken());
|
||||||
|
|
||||||
return session;
|
return session;
|
||||||
@ -77,14 +77,19 @@ public class MicrosoftLoginService implements LoginService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Profile performLogin(String microsoftToken)
|
private Profile performLogin(String microsoftToken, SavedSession previous)
|
||||||
throws IOException, InterruptedException, AuthenticationException {
|
throws IOException, InterruptedException, AuthenticationException {
|
||||||
XboxAuthorization xboxAuthorization = XboxTokenAuthorizer.authorizeWithXbox(microsoftToken);
|
XboxAuthorization xboxAuthorization = XboxTokenAuthorizer.authorizeWithXbox(microsoftToken);
|
||||||
McAuthResponse auth = MinecraftServicesAuthorizer.authorizeWithMinecraft(xboxAuthorization);
|
McAuthResponse auth = MinecraftServicesAuthorizer.authorizeWithMinecraft(xboxAuthorization);
|
||||||
McProfileResponse profile = MinecraftServicesAuthorizer.getUserProfile(auth);
|
McProfileResponse profile = MinecraftServicesAuthorizer.getUserProfile(auth);
|
||||||
|
|
||||||
Profile session = new Profile(auth, profile);
|
Profile session = new Profile(auth, profile);
|
||||||
session.setAvatarImage(VisageSkinService.fetchSkinHead(profile.getUuid()));
|
if (previous != null && previous.getAvatarImage() != null) {
|
||||||
|
session.setAvatarImage(previous.getAvatarImage());
|
||||||
|
} else {
|
||||||
|
session.setAvatarImage(VisageSkinService.fetchSkinHead(profile.getUuid()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
@ -58,10 +58,10 @@ public class YggdrasilLoginService implements LoginService {
|
|||||||
AuthenticateResponse response = req.returnContent().asJson(AuthenticateResponse.class);
|
AuthenticateResponse response = req.returnContent().asJson(AuthenticateResponse.class);
|
||||||
Profile profile = response.getSelectedProfile();
|
Profile profile = response.getSelectedProfile();
|
||||||
|
|
||||||
if (previous == null || previous.getAvatarImage() == null) {
|
if (previous != null && previous.getAvatarImage() != null) {
|
||||||
profile.setAvatarImage(VisageSkinService.fetchSkinHead(profile.getUuid()));
|
|
||||||
} else {
|
|
||||||
profile.setAvatarImage(previous.getAvatarImage());
|
profile.setAvatarImage(previous.getAvatarImage());
|
||||||
|
} else {
|
||||||
|
profile.setAvatarImage(VisageSkinService.fetchSkinHead(profile.getUuid()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return profile;
|
return profile;
|
||||||
|
Loading…
Reference in New Issue
Block a user