Report the login URL for MSA auth attempts when missing token

main
Charlotte Som 2022-02-13 07:16:45 +00:00
parent db3c6d2848
commit f3f3b21848
1 changed files with 3 additions and 10 deletions

View File

@ -35,14 +35,7 @@ public class GameAuthenticationFlow {
saveAuthData(authenticator.getResultFile()); saveAuthData(authenticator.getResultFile());
User user = userOpt.get(); User user = userOpt.get();
return new Session( return new Session(user.getName(), user.getUuid(), user.getAccessToken(), Optional.empty(), Optional.empty(), Session.AccountType.byName(user.getType()));
user.getName(),
user.getUuid(),
user.getAccessToken(),
Optional.empty(),
Optional.empty(),
Session.AccountType.byName(user.getType())
);
} }
} catch (AuthenticationException | IOException ignored) { } catch (AuthenticationException | IOException ignored) {
} }
@ -77,7 +70,7 @@ public class GameAuthenticationFlow {
String password = System.getenv("AUTH_PASSWORD"); String password = System.getenv("AUTH_PASSWORD");
if (username == null || password == null) { if (username == null || password == null) {
throw new RuntimeException("Attempted to perform Mojang authentication without AUTH_USERNAME or AUTH_PASSWORD set"); throw new RuntimeException("Attempted to perform Mojang authentication without AUTH_USERNAME or AUTH_PASSWORD set.");
} }
return Authenticator.ofYggdrasil("-", username, password).shouldAuthenticate(); return Authenticator.ofYggdrasil("-", username, password).shouldAuthenticate();
@ -86,7 +79,7 @@ public class GameAuthenticationFlow {
private static Authenticator.Builder createMicrosoftAuthenticator() { private static Authenticator.Builder createMicrosoftAuthenticator() {
String token = System.getenv("AUTH_TOKEN"); String token = System.getenv("AUTH_TOKEN");
if (token == null) { if (token == null) {
throw new RuntimeException("Attempted to perform Microsoft authentication without AUTH_TOKEN set"); throw new RuntimeException("Attempted to perform Microsoft authentication without AUTH_TOKEN set. You may want to visit " + Authenticator.microsoftLogin());
} }
return Authenticator.ofMicrosoft(token).shouldAuthenticate(); return Authenticator.ofMicrosoft(token).shouldAuthenticate();