From c932f9c7e5389868c958456f2cdb33ddf3d6382b Mon Sep 17 00:00:00 2001 From: Benjamin Elsdon Date: Wed, 11 May 2022 20:35:27 +0800 Subject: [PATCH] Add verifyUser to AuthenticationHandler --- .../dispatch/authentication/AuthenticationHandler.java | 7 +++++++ .../authentication/DefaultAuthenticationHandler.java | 6 ++++++ src/main/resources/languages/en-US.json | 3 +++ 3 files changed, 16 insertions(+) diff --git a/src/main/java/emu/grasscutter/server/dispatch/authentication/AuthenticationHandler.java b/src/main/java/emu/grasscutter/server/dispatch/authentication/AuthenticationHandler.java index 92a2961ea..e644a9f1d 100644 --- a/src/main/java/emu/grasscutter/server/dispatch/authentication/AuthenticationHandler.java +++ b/src/main/java/emu/grasscutter/server/dispatch/authentication/AuthenticationHandler.java @@ -12,5 +12,12 @@ public interface AuthenticationHandler { void handleRegister(Request req, Response res); void handleChangePassword(Request req, Response res); + /** + * Other plugins may need to verify a user's identity using details from handleLogin() + * @param details The user's unique one-time token that needs to be verified + * @return If the verification was successful + */ + boolean verifyUser(String details); + LoginResultJson handleGameLogin(Request req, LoginAccountRequestJson requestData); } diff --git a/src/main/java/emu/grasscutter/server/dispatch/authentication/DefaultAuthenticationHandler.java b/src/main/java/emu/grasscutter/server/dispatch/authentication/DefaultAuthenticationHandler.java index 67b3d4023..122e04ff6 100644 --- a/src/main/java/emu/grasscutter/server/dispatch/authentication/DefaultAuthenticationHandler.java +++ b/src/main/java/emu/grasscutter/server/dispatch/authentication/DefaultAuthenticationHandler.java @@ -28,6 +28,12 @@ public class DefaultAuthenticationHandler implements AuthenticationHandler { res.send("Authentication is not available with the default authentication method"); } + @Override + public boolean verifyUser(String details) { + Grasscutter.getLogger().info(translate("dispatch.authentication.default_unable_to_verify")); + return false; + } + @Override public LoginResultJson handleGameLogin(Request req, LoginAccountRequestJson requestData) { LoginResultJson responseData = new LoginResultJson(); diff --git a/src/main/resources/languages/en-US.json b/src/main/resources/languages/en-US.json index c9c3c0c70..2b392b682 100644 --- a/src/main/resources/languages/en-US.json +++ b/src/main/resources/languages/en-US.json @@ -16,6 +16,9 @@ "no_keystore_error": "[Dispatch] No SSL cert found! Falling back to HTTP server.", "default_password": "[Dispatch] The default keystore password was loaded successfully. Please consider setting the password to 123456 in config.json." }, + "authentication": { + "default_unable_to_verify": "[Authentication] Something called the verifyUser method which is unavailable in the default authentication handler" + }, "no_commands_error": "Commands are not supported in dispatch only mode.", "unhandled_request_error": "[Dispatch] Potential unhandled %s request: %s", "account": {