diff options
Diffstat (limited to 'loader')
3 files changed, 13 insertions, 9 deletions
diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/auth/AuthManager.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/auth/AuthManager.java index 206ed0fb..b75c5100 100644 --- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/auth/AuthManager.java +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/auth/AuthManager.java @@ -67,15 +67,19 @@ public class AuthManager { final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1, namedThreadFactory); scheduler.scheduleAtFixedRate(() -> { boolean shouldReAuth = false; - if (!getToken().getUID().replace("-", "").equals(Minecraft.getMinecraft().getSession().getPlayerID())) { + if (getToken().isUserVerified() && !getToken().getUUID().replace("-", "").equals(Minecraft.getMinecraft().getSession().getPlayerID())) { shouldReAuth = true; } if (!getToken().isAuthenticated()) { shouldReAuth = true; } if (shouldReAuth) - reAuth(); - }, 10,2000, TimeUnit.MILLISECONDS); + try { + reAuth(); + } catch (Exception e) { + e.printStackTrace(); + } + }, 10,10000, TimeUnit.MILLISECONDS); reAuth(); @@ -140,7 +144,7 @@ public class AuthManager { } - public AuthToken acceptPrivacyPolicy() { + public AuthToken acceptPrivacyPolicy(long version) { if (reauthLock) { while(reauthLock); return currentToken; @@ -150,7 +154,7 @@ public class AuthManager { reauthLock = true; NotificationManager.INSTANCE.removeNotification(privacyPolicyRequired); try { - currentToken = DgAuthUtil.acceptNewPrivacyPolicy(currentToken.getToken()); + currentToken = DgAuthUtil.acceptNewPrivacyPolicy(currentToken.getToken(), version); if (currentToken instanceof PrivacyPolicyRequiredToken) throw new PrivacyPolicyRequiredException(); } catch (Exception e) { if (e instanceof PrivacyPolicyRequiredException) { diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/auth/DgAuthUtil.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/auth/DgAuthUtil.java index be247c88..803ac41a 100644 --- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/auth/DgAuthUtil.java +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/auth/DgAuthUtil.java @@ -145,7 +145,7 @@ public class DgAuthUtil { } } - public static AuthToken acceptNewPrivacyPolicy(String tempToken) throws IOException { + public static AuthToken acceptNewPrivacyPolicy(String tempToken, long version) throws IOException { HttpURLConnection urlConnection = (HttpURLConnection) new URL(Main.DOMAIN + "/auth/v2/acceptPrivacyPolicy").openConnection(); urlConnection.setRequestMethod("POST"); urlConnection.setRequestProperty("User-Agent", "DungeonsGuide/1.0"); @@ -153,7 +153,7 @@ public class DgAuthUtil { urlConnection.setDoInput(true); urlConnection.setDoOutput(true); - urlConnection.getOutputStream().write(tempToken.getBytes()); + urlConnection.getOutputStream().write(("{\"jwt\": \""+tempToken+"\", \"version\": "+version+"}").getBytes()); JSONObject data = getResponse(urlConnection, JSONObject.class); try { diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/GuiPrivacyPolicy.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/GuiPrivacyPolicy.java index c5a1ea00..d276b4b9 100644 --- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/GuiPrivacyPolicy.java +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/gui/screen/GuiPrivacyPolicy.java @@ -27,8 +27,8 @@ public class GuiPrivacyPolicy extends SpecialGuiScreen { if (button.id == 0) { // accept try { - AuthManager.getInstance().acceptPrivacyPolicy(); - } catch (PrivacyPolicyRequiredException e) { + AuthManager.getInstance().acceptPrivacyPolicy(1); + } catch (Exception e) { e.printStackTrace(); // GuiDisplayer.INSTANCE.displayGui(new GuiLoadingError(e)); // display tooltip. |