diff --git a/build.gradle b/build.gradle index c3f09a3..ac3a21e 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ sourceCompatibility = 17 targetCompatibility = 17 group 'me.exzork.gcauth' -version '2.1.5' +version '2.1.6' repositories { mavenCentral() diff --git a/src/main/java/me/exzork/gcauth/Config.java b/src/main/java/me/exzork/gcauth/Config.java index 6940900..f0dba1c 100644 --- a/src/main/java/me/exzork/gcauth/Config.java +++ b/src/main/java/me/exzork/gcauth/Config.java @@ -5,5 +5,6 @@ import me.exzork.gcauth.utils.Authentication; public final class Config { public String Hash = "BCRYPT"; public String jwtSecret = Authentication.generateRandomString(32); + public String[] defaultPermissions = new String[]{""}; public String ACCESS_KEY = ""; } diff --git a/src/main/java/me/exzork/gcauth/handler/RegisterHandler.java b/src/main/java/me/exzork/gcauth/handler/RegisterHandler.java index 9893c5f..beb88a8 100644 --- a/src/main/java/me/exzork/gcauth/handler/RegisterHandler.java +++ b/src/main/java/me/exzork/gcauth/handler/RegisterHandler.java @@ -18,7 +18,7 @@ public class RegisterHandler implements HttpContextHandler { @Override public void handle(Request request, Response response) throws IOException { AuthResponseJson authResponse = new AuthResponseJson(); - + Account account = null; try { String requestBody = request.ctx().body(); if (requestBody.isEmpty()) { @@ -36,7 +36,7 @@ public class RegisterHandler implements HttpContextHandler { if (registerAccount.password.length() >= 8) { String password = Authentication.generateHash(registerAccount.password); try{ - Account account = Authentication.getAccountByUsernameAndPassword(registerAccount.username, ""); + account = Authentication.getAccountByUsernameAndPassword(registerAccount.username, ""); if (account != null) { account.setPassword(password); account.save(); @@ -79,7 +79,13 @@ public class RegisterHandler implements HttpContextHandler { Grasscutter.getLogger().error("[Dispatch] An error occurred while creating an account."); e.printStackTrace(); } - + if (authResponse.success) { + if (GCAuth.getConfigStatic().defaultPermissions.length > 0) { + for (String permission : GCAuth.getConfigStatic().defaultPermissions) { + account.addPermission(permission); + } + } + } response.send(authResponse); } }