mirror of
https://github.com/SKCraft/Launcher.git
synced 2024-11-27 12:46:22 +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);
|
||||
});
|
||||
|
||||
Profile session = performLogin(response.getAccessToken());
|
||||
Profile session = performLogin(response.getAccessToken(), null);
|
||||
session.setRefreshToken(response.getRefreshToken());
|
||||
|
||||
return session;
|
||||
@ -52,7 +52,7 @@ public class MicrosoftLoginService implements LoginService {
|
||||
form.add("refresh_token", savedSession.getRefreshToken());
|
||||
});
|
||||
|
||||
Profile session = performLogin(response.getAccessToken());
|
||||
Profile session = performLogin(response.getAccessToken(), savedSession);
|
||||
session.setRefreshToken(response.getRefreshToken());
|
||||
|
||||
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 {
|
||||
XboxAuthorization xboxAuthorization = XboxTokenAuthorizer.authorizeWithXbox(microsoftToken);
|
||||
McAuthResponse auth = MinecraftServicesAuthorizer.authorizeWithMinecraft(xboxAuthorization);
|
||||
McProfileResponse profile = MinecraftServicesAuthorizer.getUserProfile(auth);
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -58,10 +58,10 @@ public class YggdrasilLoginService implements LoginService {
|
||||
AuthenticateResponse response = req.returnContent().asJson(AuthenticateResponse.class);
|
||||
Profile profile = response.getSelectedProfile();
|
||||
|
||||
if (previous == null || previous.getAvatarImage() == null) {
|
||||
profile.setAvatarImage(VisageSkinService.fetchSkinHead(profile.getUuid()));
|
||||
} else {
|
||||
if (previous != null && previous.getAvatarImage() != null) {
|
||||
profile.setAvatarImage(previous.getAvatarImage());
|
||||
} else {
|
||||
profile.setAvatarImage(VisageSkinService.fetchSkinHead(profile.getUuid()));
|
||||
}
|
||||
|
||||
return profile;
|
||||
|
Loading…
Reference in New Issue
Block a user