diff options
author | syeyoung <cyoung06@naver.com> | 2022-11-17 02:49:56 +0900 |
---|---|---|
committer | syeyoung <cyoung06@naver.com> | 2022-11-17 02:49:56 +0900 |
commit | 573e44eda970c4fb08b3e213d27845529efba2f1 (patch) | |
tree | e960c067c0e8fbd865bd508caaea180c861bf35f /loader/src/main/java/kr | |
parent | c896329a449045e3def2ff05ca801ec8e1b4a480 (diff) | |
download | Skyblock-Dungeons-Guide-573e44eda970c4fb08b3e213d27845529efba2f1.tar.gz Skyblock-Dungeons-Guide-573e44eda970c4fb08b3e213d27845529efba2f1.tar.bz2 Skyblock-Dungeons-Guide-573e44eda970c4fb08b3e213d27845529efba2f1.zip |
- Backend now accepts policy version
Signed-off-by: syeyoung <cyoung06@naver.com>
Diffstat (limited to 'loader/src/main/java/kr')
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. |