1
0
mirror of https://github.com/SKCraft/Launcher.git synced 2025-01-05 19:09:03 +01:00

Improve authentication error messages

This commit is contained in:
Henry Le Grys 2021-02-09 03:06:37 +00:00
parent b189173b34
commit 6b442c771e
4 changed files with 14 additions and 6 deletions

View File

@ -17,6 +17,10 @@ public class AuthenticationException extends LauncherException {
super(message, localizedMessage);
}
public AuthenticationException(String message) {
super(message, message);
}
public AuthenticationException(Throwable cause, String localizedMessage) {
super(cause, localizedMessage);
}

View File

@ -73,7 +73,7 @@ public class MicrosoftLoginService implements LoginService {
} else {
TokenError error = request.returnContent().asJson(TokenError.class);
throw new AuthenticationException(error.errorDescription, error.errorDescription);
throw new AuthenticationException(error.errorDescription);
}
}

View File

@ -11,7 +11,6 @@ import com.skcraft.launcher.util.HttpRequest;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.ToString;
import lombok.extern.java.Log;
import java.io.IOException;
import java.net.URL;
@ -21,7 +20,6 @@ import java.util.Map;
/**
* Creates authenticated sessions using the Mojang Yggdrasil login protocol.
*/
@Log
@RequiredArgsConstructor
public class YggdrasilLoginService implements LoginService {
@ -52,8 +50,8 @@ public class YggdrasilLoginService implements LoginService {
if (req.getResponseCode() != 200) {
ErrorResponse error = req.returnContent().asJson(ErrorResponse.class);
log.warning(error.toString());
throw new AuthenticationException(error.getErrorMessage(), error.getErrorMessage());
throw new AuthenticationException(error.getErrorMessage());
} else {
AuthenticateResponse response = req.returnContent().asJson(AuthenticateResponse.class);
Profile profile = response.getSelectedProfile();

View File

@ -3,6 +3,7 @@ package com.skcraft.launcher.auth.microsoft;
import com.skcraft.launcher.auth.AuthenticationException;
import com.skcraft.launcher.auth.microsoft.model.*;
import com.skcraft.launcher.util.HttpRequest;
import com.skcraft.launcher.util.SharedLocale;
import java.io.IOException;
import java.net.URL;
@ -36,7 +37,12 @@ public class MinecraftServicesAuthorizer {
} else {
McServicesError error = request.returnContent().asJson(McServicesError.class);
throw new AuthenticationException(error.getErrorMessage(), error.getErrorMessage());
if (error.getError().equals("NOT_FOUND")) {
throw new AuthenticationException("No Minecraft profile",
SharedLocale.tr("login.minecraftNotOwnedError"));
}
throw new AuthenticationException(error.getErrorMessage());
}
}
}