diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/YggdrasilAccount.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/YggdrasilAccount.java index d178b6951f0..a789f7112b5 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/YggdrasilAccount.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/yggdrasil/YggdrasilAccount.java @@ -103,35 +103,30 @@ public UUID getProfileID() { @Override public synchronized AuthInfo logIn() throws AuthenticationException { - if (!authenticated || !session.hasProfileName()) { - if (session.hasProfileName() && service.validate(session.getAccessToken(), session.getClientToken())) { - authenticated = true; - } else { - YggdrasilSession acquiredSession; - try { - acquiredSession = service.refresh(session.getAccessToken(), session.getClientToken(), null); - } catch (RemoteAuthenticationException e) { - if ("ForbiddenOperationException".equals(e.getRemoteName())) { - throw new CredentialExpiredException(e); - } else { - throw e; - } - } - if (acquiredSession.getSelectedProfile() == null || - !acquiredSession.getSelectedProfile().getId().equals(profileID)) { - throw new ServerResponseMalformedException("Selected profile changed"); - } - if (!acquiredSession.hasProfileName()) { - throw new ServerResponseMalformedException("Profile name is missing"); + if (!authenticated || !session.hasProfileName() || !service.validate(session.getAccessToken(), session.getClientToken())) { + YggdrasilSession acquiredSession; + try { + acquiredSession = service.refresh(session.getAccessToken(), session.getClientToken(), null); + } catch (RemoteAuthenticationException e) { + if ("ForbiddenOperationException".equals(e.getRemoteName())) { + throw new CredentialExpiredException(e); + } else { + throw e; } + } + if (acquiredSession.getSelectedProfile() == null || + !acquiredSession.getSelectedProfile().getId().equals(profileID)) { + throw new ServerResponseMalformedException("Selected profile changed"); + } + if (!acquiredSession.hasProfileName()) { + throw new ServerResponseMalformedException("Profile name is missing"); + } - session = acquiredSession; + session = acquiredSession; - authenticated = true; - invalidate(); - } + authenticated = true; + invalidate(); } - return session.toAuthInfo(); }