auth: Always check token.exp when launch game (#2642)

* auth: Always check token.exp when launch game

fix #2048

* Remove wrong notAfter check
This commit is contained in:
Kevin Z 2024-01-12 20:53:47 -07:00 committed by GitHub
parent 2116cfd789
commit 8678c0dcf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -84,20 +84,16 @@ public class MicrosoftAccount extends OAuthAccount {
@Override
public AuthInfo logIn() throws AuthenticationException {
if (!authenticated) {
if (service.validate(session.getNotAfter(), session.getTokenType(), session.getAccessToken())) {
authenticated = true;
} else {
MicrosoftSession acquiredSession = service.refresh(session);
if (!Objects.equals(acquiredSession.getProfile().getId(), session.getProfile().getId())) {
throw new ServerResponseMalformedException("Selected profile changed");
}
session = acquiredSession;
authenticated = true;
invalidate();
if (!authenticated || !service.validate(session.getNotAfter(), session.getTokenType(), session.getAccessToken())) {
MicrosoftSession acquiredSession = service.refresh(session);
if (!Objects.equals(acquiredSession.getProfile().getId(), session.getProfile().getId())) {
throw new ServerResponseMalformedException("Selected profile changed");
}
session = acquiredSession;
authenticated = true;
invalidate();
}
return session.toAuthInfo();