mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
[FIX] No refresh in client
This commit is contained in:
parent
fe374c1f9e
commit
54bfc6de9c
4 changed files with 17 additions and 11 deletions
|
@ -57,7 +57,7 @@ public void run(String[] args) {
|
||||||
if(uuid == null) {
|
if(uuid == null) {
|
||||||
if(accessToken != null) {
|
if(accessToken != null) {
|
||||||
Request.setOAuth(authId, new AuthRequestEvent.OAuthRequestEvent(accessToken, refreshToken, expire));
|
Request.setOAuth(authId, new AuthRequestEvent.OAuthRequestEvent(accessToken, refreshToken, expire));
|
||||||
Request.RequestRestoreReport report = Request.restore(true, false);
|
Request.RequestRestoreReport report = Request.restore(true, false, true);
|
||||||
permissions = report.userInfo.permissions;
|
permissions = report.userInfo.permissions;
|
||||||
username = report.userInfo.playerProfile.username;
|
username = report.userInfo.playerProfile.username;
|
||||||
uuid = report.userInfo.playerProfile.uuid.toString();
|
uuid = report.userInfo.playerProfile.uuid.toString();
|
||||||
|
|
|
@ -159,7 +159,7 @@ public static void reconnect() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RequestRestoreReport restore() throws Exception {
|
public static RequestRestoreReport restore() throws Exception {
|
||||||
return restore(false, false);
|
return restore(false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized static Map<String, String> getExpiredExtendedTokens() {
|
private synchronized static Map<String, String> getExpiredExtendedTokens() {
|
||||||
|
@ -178,16 +178,22 @@ private synchronized static Map<String, String> getExpiredExtendedTokens() {
|
||||||
return makeNewTokens(set);
|
return makeNewTokens(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized RequestRestoreReport restore(boolean needUserInfo, boolean refreshOnly) throws Exception {
|
public static synchronized RequestRestoreReport restore(boolean needUserInfo, boolean refreshOnly, boolean noRefresh) throws Exception {
|
||||||
boolean refreshed = false;
|
boolean refreshed = false;
|
||||||
RestoreRequest request;
|
RestoreRequest request;
|
||||||
if (oauth != null) {
|
if (oauth != null) {
|
||||||
if (isTokenExpired() || oauth.accessToken == null) {
|
if(isTokenExpired() || oauth.accessToken == null) {
|
||||||
|
if(noRefresh) {
|
||||||
|
oauth = null;
|
||||||
|
} else {
|
||||||
RefreshTokenRequest refreshRequest = new RefreshTokenRequest(authId, oauth.refreshToken);
|
RefreshTokenRequest refreshRequest = new RefreshTokenRequest(authId, oauth.refreshToken);
|
||||||
RefreshTokenRequestEvent event = refreshRequest.request();
|
RefreshTokenRequestEvent event = refreshRequest.request();
|
||||||
setOAuth(authId, event.oauth);
|
setOAuth(authId, event.oauth);
|
||||||
refreshed = true;
|
refreshed = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (oauth != null) {
|
||||||
request = new RestoreRequest(authId, oauth.accessToken, refreshOnly ? getExpiredExtendedTokens() : getStringExtendedTokens(), needUserInfo);
|
request = new RestoreRequest(authId, oauth.accessToken, refreshOnly ? getExpiredExtendedTokens() : getStringExtendedTokens(), needUserInfo);
|
||||||
} else {
|
} else {
|
||||||
request = new RestoreRequest(authId, null, refreshOnly ? getExpiredExtendedTokens() : getStringExtendedTokens(), false);
|
request = new RestoreRequest(authId, null, refreshOnly ? getExpiredExtendedTokens() : getStringExtendedTokens(), false);
|
||||||
|
|
|
@ -124,7 +124,7 @@ private static void realMain(String[] args) throws Throwable {
|
||||||
service = StdWebSocketService.initWebSockets(Launcher.getConfig().address).get();
|
service = StdWebSocketService.initWebSockets(Launcher.getConfig().address).get();
|
||||||
Request.setRequestService(service);
|
Request.setRequestService(service);
|
||||||
LogHelper.debug("Restore sessions");
|
LogHelper.debug("Restore sessions");
|
||||||
Request.restore();
|
Request.restore(false, false, true);
|
||||||
service.registerEventHandler(new BasicLauncherEventHandler());
|
service.registerEventHandler(new BasicLauncherEventHandler());
|
||||||
((StdWebSocketService) service).reconnectCallback = () ->
|
((StdWebSocketService) service).reconnectCallback = () ->
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,9 +6,9 @@ public final class Version implements Comparable<Version> {
|
||||||
|
|
||||||
public static final int MAJOR = 5;
|
public static final int MAJOR = 5;
|
||||||
public static final int MINOR = 5;
|
public static final int MINOR = 5;
|
||||||
public static final int PATCH = 2;
|
public static final int PATCH = 3;
|
||||||
public static final int BUILD = 1;
|
public static final int BUILD = 1;
|
||||||
public static final Version.Type RELEASE = Type.STABLE;
|
public static final Version.Type RELEASE = Type.DEV;
|
||||||
public final int major;
|
public final int major;
|
||||||
public final int minor;
|
public final int minor;
|
||||||
public final int patch;
|
public final int patch;
|
||||||
|
|
Loading…
Reference in a new issue