From 10fe5d11caf31fe19f3dd6432b9c4482d467631e Mon Sep 17 00:00:00 2001 From: Benjamin Elsdon Date: Tue, 17 May 2022 20:18:12 +0800 Subject: [PATCH] AuthenticationSystem::verifyUser now returns the user's Account instead of a boolean --- .../java/emu/grasscutter/auth/AuthenticationSystem.java | 7 ++++--- .../java/emu/grasscutter/auth/DefaultAuthentication.java | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/emu/grasscutter/auth/AuthenticationSystem.java b/src/main/java/emu/grasscutter/auth/AuthenticationSystem.java index 41aba1c8e..c9ae98d50 100644 --- a/src/main/java/emu/grasscutter/auth/AuthenticationSystem.java +++ b/src/main/java/emu/grasscutter/auth/AuthenticationSystem.java @@ -1,5 +1,6 @@ package emu.grasscutter.auth; +import emu.grasscutter.game.Account; import emu.grasscutter.server.http.objects.*; import express.http.Request; import express.http.Response; @@ -30,10 +31,10 @@ public interface AuthenticationSystem { /** * Called by plugins to internally verify a user's identity. - * @param details A unique, one-time token to verify the user. - * @return True if the user is verified, False otherwise. + * @param details A unique identifier to identify the user. (For example: a JWT token) + * @return The user's account if the verification was successful, null if the user was unable to be verified. */ - boolean verifyUser(String details); + Account verifyUser(String details); /** * This is the authenticator used for password authentication. diff --git a/src/main/java/emu/grasscutter/auth/DefaultAuthentication.java b/src/main/java/emu/grasscutter/auth/DefaultAuthentication.java index 08958d8e9..b47985cf6 100644 --- a/src/main/java/emu/grasscutter/auth/DefaultAuthentication.java +++ b/src/main/java/emu/grasscutter/auth/DefaultAuthentication.java @@ -2,6 +2,7 @@ package emu.grasscutter.auth; import emu.grasscutter.Grasscutter; import emu.grasscutter.auth.DefaultAuthenticators.*; +import emu.grasscutter.game.Account; import emu.grasscutter.server.http.objects.ComboTokenResJson; import emu.grasscutter.server.http.objects.LoginResultJson; @@ -26,11 +27,11 @@ public final class DefaultAuthentication implements AuthenticationSystem { public void resetPassword(String username) { // Unhandled. The default authenticator doesn't store passwords. } - + @Override - public boolean verifyUser(String details) { + public Account verifyUser(String details) { Grasscutter.getLogger().info(translate("dispatch.authentication.default_unable_to_verify")); - return false; + return null; } @Override