change getPlayerUid and use plugin logger

This commit is contained in:
muhammadeko 2022-05-29 18:10:05 +07:00
parent ac1c4b57d2
commit 738a642dba
No known key found for this signature in database
GPG Key ID: 51366716C10E98B1
5 changed files with 14 additions and 12 deletions

View File

@ -3,12 +3,13 @@
Grasscutter Authentication System
### Version Compatibility
| GCAuth | Grasscutter Development | Grasscutter Stable |
|---------------|-------------------------|--------------------|
| 2.2.1+ | 1.1.2-dev | - |
| 2.1.4 - 2.1.6 | 1.1.1-dev | - |
| 2.0.0 - 2.1.3 | 1.0.3-dev | 1.1.0 |
| 1.0.0 | 1.0.2-dev | - |
| GCAuth | Grasscutter Development | Grasscutter Stable |
|---------------|--------------------------------------------------------------------------------------------------------------------------------|--------------------|
| 2.3.1+ | 1.1.2-dev ( [141b191](https://github.com/Grasscutters/Grasscutter/commit/ce07f56f9d10cc79c9b7104b66c2e4ff19cd4f53) and after ) | - |
| 2.2.1 - 2.3.0 | 1.1.2-dev ( before [141b191](https://github.com/Grasscutters/Grasscutter/commit/ce07f56f9d10cc79c9b7104b66c2e4ff19cd4f53) ) | - |
| 2.1.4 - 2.1.6 | 1.1.1-dev | - |
| 2.0.0 - 2.1.3 | 1.0.3-dev | 1.1.0 |
| 1.0.0 | 1.0.2-dev | - |
### Usage :
- Place jar inside plugins folder of Grasscutter.

View File

@ -10,7 +10,7 @@ sourceCompatibility = 17
targetCompatibility = 17
group 'me.exzork.gcauth'
version '2.3.0'
version '2.3.1'
repositories {
mavenCentral()

View File

@ -56,7 +56,7 @@ public class GCAuthExternalAuthenticator implements ExternalAuthenticator {
authResponse.success = false;
authResponse.message = "UNKNOWN"; // ENG = "An unknown error has occurred..."
authResponse.jwt = "";
Grasscutter.getLogger().error("[Dispatch] An error occurred while a user was logging in.");
GCAuth.getInstance().getLogger().error("[Dispatch] An error occurred while a user was logging in.");
e.printStackTrace();
}
response.send(authResponse);
@ -126,7 +126,7 @@ public class GCAuthExternalAuthenticator implements ExternalAuthenticator {
authResponse.success = false;
authResponse.message = "UNKNOWN"; // ENG = "An unknown error has occurred..."
authResponse.jwt = "";
Grasscutter.getLogger().error("[Dispatch] An error occurred while creating an account.");
GCAuth.getInstance().getLogger().error("[Dispatch] An error occurred while creating an account.");
e.printStackTrace();
}
if (authResponse.success) {
@ -190,7 +190,7 @@ public class GCAuthExternalAuthenticator implements ExternalAuthenticator {
authResponse.success = false;
authResponse.message = "UNKNOWN"; // ENG = "An unknown error has occurred..."
authResponse.jwt = "";
Grasscutter.getLogger().error("[Dispatch] Error while changing user password.");
GCAuth.getInstance().getLogger().error("[Dispatch] Error while changing user password.");
e.printStackTrace();
}
response.send(authResponse);

View File

@ -5,6 +5,7 @@ import emu.grasscutter.auth.AuthenticationSystem;
import emu.grasscutter.auth.Authenticator;
import emu.grasscutter.game.Account;
import emu.grasscutter.server.http.objects.LoginResultJson;
import me.exzork.gcauth.GCAuth;
import me.exzork.gcauth.utils.Authentication;
public class GCAuthenticators {
@ -31,7 +32,7 @@ public class GCAuthenticators {
response.data.account.token = account.generateSessionKey();
response.data.account.email = account.getEmail();
Grasscutter.getLogger().info("[GCAuth] Client " + requestData.account + " logged in");
GCAuth.getInstance().getLogger().info("[GCAuth] Client " + requestData.account + " logged in");
return response;
}
}

View File

@ -71,7 +71,7 @@ public final class Authentication {
return JWT.create()
.withClaim("token", otp)
.withClaim("username", account.getUsername())
.withClaim("uid", account.getPlayerUid())
.withClaim("uid", account.getReservedPlayerUid())
.withExpiresAt(Date.from(Instant.ofEpochSecond(System.currentTimeMillis() / 1000 + GCAuth.getInstance().getConfig().jwtExpiration)))
.sign(key);
}