mirror of
https://github.com/exzork/GCAuth.git
synced 2024-11-30 18:58:54 +00:00
move add permissions code
This commit is contained in:
parent
279c50393e
commit
0fc6ed259a
@ -18,7 +18,7 @@ public class RegisterHandler implements HttpContextHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void handle(Request request, Response response) throws IOException {
|
public void handle(Request request, Response response) throws IOException {
|
||||||
AuthResponseJson authResponse = new AuthResponseJson();
|
AuthResponseJson authResponse = new AuthResponseJson();
|
||||||
|
Account account = null;
|
||||||
try {
|
try {
|
||||||
String requestBody = request.ctx().body();
|
String requestBody = request.ctx().body();
|
||||||
if (requestBody.isEmpty()) {
|
if (requestBody.isEmpty()) {
|
||||||
@ -36,7 +36,7 @@ public class RegisterHandler implements HttpContextHandler {
|
|||||||
if (registerAccount.password.length() >= 8) {
|
if (registerAccount.password.length() >= 8) {
|
||||||
String password = Authentication.generateHash(registerAccount.password);
|
String password = Authentication.generateHash(registerAccount.password);
|
||||||
try{
|
try{
|
||||||
Account account = Authentication.getAccountByUsernameAndPassword(registerAccount.username, "");
|
account = Authentication.getAccountByUsernameAndPassword(registerAccount.username, "");
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
account.setPassword(password);
|
account.setPassword(password);
|
||||||
account.save();
|
account.save();
|
||||||
@ -79,7 +79,13 @@ public class RegisterHandler implements HttpContextHandler {
|
|||||||
Grasscutter.getLogger().error("[Dispatch] An error occurred while creating an account.");
|
Grasscutter.getLogger().error("[Dispatch] An error occurred while creating an account.");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
if (authResponse.success) {
|
||||||
|
if (GCAuth.getConfigStatic().defaultPermissions.length > 0) {
|
||||||
|
for (String permission : GCAuth.getConfigStatic().defaultPermissions) {
|
||||||
|
account.addPermission(permission);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
response.send(authResponse);
|
response.send(authResponse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user