mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-17 01:15:52 +01:00
Format code [skip actions]
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
package emu.grasscutter.auth;
|
||||
|
||||
import static emu.grasscutter.config.Configuration.ACCOUNT;
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
import at.favre.lib.crypto.bcrypt.BCrypt;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.auth.AuthenticationSystem.AuthenticationRequest;
|
||||
@@ -13,17 +16,13 @@ import emu.grasscutter.utils.DispatchUtils;
|
||||
import emu.grasscutter.utils.FileUtils;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
import io.javalin.http.ContentType;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.KeyFactory;
|
||||
import java.security.interfaces.RSAPrivateKey;
|
||||
import java.security.spec.PKCS8EncodedKeySpec;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static emu.grasscutter.config.Configuration.ACCOUNT;
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
import javax.crypto.Cipher;
|
||||
|
||||
/** A class containing default authenticators. */
|
||||
public final class DefaultAuthenticators {
|
||||
@@ -382,8 +381,7 @@ public final class DefaultAuthenticators {
|
||||
|
||||
public HandbookAuthentication() {
|
||||
try {
|
||||
this.authPage = new String(
|
||||
FileUtils.readResource("/html/handbook_auth.html"));
|
||||
this.authPage = new String(FileUtils.readResource("/html/handbook_auth.html"));
|
||||
} catch (Exception ignored) {
|
||||
throw new RuntimeException("Failed to load handbook auth page.");
|
||||
}
|
||||
@@ -395,8 +393,7 @@ public final class DefaultAuthenticators {
|
||||
if (ctx == null) return;
|
||||
|
||||
// Respond with the handbook auth page.
|
||||
ctx.contentType(ContentType.TEXT_HTML)
|
||||
.result(this.authPage);
|
||||
ctx.contentType(ContentType.TEXT_HTML).result(this.authPage);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -407,28 +404,27 @@ public final class DefaultAuthenticators {
|
||||
// Get the body data.
|
||||
var playerId = ctx.formParam("playerid");
|
||||
if (playerId == null) {
|
||||
return Response.builder().status(400)
|
||||
.body("Invalid player ID.").build();
|
||||
return Response.builder().status(400).body("Invalid player ID.").build();
|
||||
}
|
||||
|
||||
try {
|
||||
// Get the player's session token.
|
||||
var sessionKey = DispatchUtils.fetchSessionKey(
|
||||
Integer.parseInt(playerId));
|
||||
var sessionKey = DispatchUtils.fetchSessionKey(Integer.parseInt(playerId));
|
||||
if (sessionKey == null) {
|
||||
return Response.builder().status(400)
|
||||
.body("Invalid player ID.").build();
|
||||
return Response.builder().status(400).body("Invalid player ID.").build();
|
||||
}
|
||||
|
||||
// Check if the account is banned.
|
||||
return Response.builder().status(200)
|
||||
.body(this.authPage.replace("{{VALUE}}", "true")
|
||||
.replace("{{SESSION_TOKEN}}", sessionKey)
|
||||
.replace("{{PLAYER_ID}}", playerId))
|
||||
.build();
|
||||
return Response.builder()
|
||||
.status(200)
|
||||
.body(
|
||||
this.authPage
|
||||
.replace("{{VALUE}}", "true")
|
||||
.replace("{{SESSION_TOKEN}}", sessionKey)
|
||||
.replace("{{PLAYER_ID}}", playerId))
|
||||
.build();
|
||||
} catch (NumberFormatException ignored) {
|
||||
return Response.builder().status(500)
|
||||
.body("Invalid player ID.").build();
|
||||
return Response.builder().status(500).body("Invalid player ID.").build();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user