mirror of
https://github.com/exzork/GCAuth.git
synced 2024-11-30 18:58:54 +00:00
fix registerhandler and bump version
This commit is contained in:
parent
d08aba15ee
commit
1a7305adf6
@ -10,7 +10,7 @@ sourceCompatibility = 17
|
|||||||
targetCompatibility = 17
|
targetCompatibility = 17
|
||||||
|
|
||||||
group 'me.exzork.gcauth'
|
group 'me.exzork.gcauth'
|
||||||
version '2.1.2'
|
version '2.1.3'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
@ -29,24 +29,30 @@ public class RegisterHandler implements HttpContextHandler {
|
|||||||
if (registerAccount.password.equals(registerAccount.password_confirmation)) {
|
if (registerAccount.password.equals(registerAccount.password_confirmation)) {
|
||||||
if (registerAccount.password.length() >= 8) {
|
if (registerAccount.password.length() >= 8) {
|
||||||
String password = Authentication.generateHash(registerAccount.password);
|
String password = Authentication.generateHash(registerAccount.password);
|
||||||
Account account = Authentication.getAccountByUsernameAndPassword(registerAccount.username, "");
|
try{
|
||||||
if (account != null) {
|
Account account = Authentication.getAccountByUsernameAndPassword(registerAccount.username, "");
|
||||||
account.setPassword(password);
|
if (account != null) {
|
||||||
account.save();
|
account.setPassword(password);
|
||||||
authResponse.success = true;
|
account.save();
|
||||||
authResponse.message = "";
|
|
||||||
authResponse.jwt = "";
|
|
||||||
} else {
|
|
||||||
account = DatabaseHelper.createAccountWithPassword(registerAccount.username, password);
|
|
||||||
if (account == null) {
|
|
||||||
authResponse.success = false;
|
|
||||||
authResponse.message = "USERNAME_TAKEN"; // ENG = "Username has already been taken by another user."
|
|
||||||
authResponse.jwt = "";
|
|
||||||
} else {
|
|
||||||
authResponse.success = true;
|
authResponse.success = true;
|
||||||
authResponse.message = "";
|
authResponse.message = "";
|
||||||
authResponse.jwt = "";
|
authResponse.jwt = "";
|
||||||
|
} else {
|
||||||
|
account = DatabaseHelper.createAccountWithPassword(registerAccount.username, password);
|
||||||
|
if (account == null) {
|
||||||
|
authResponse.success = false;
|
||||||
|
authResponse.message = "USERNAME_TAKEN"; // ENG = "Username has already been taken by another user."
|
||||||
|
authResponse.jwt = "";
|
||||||
|
} else {
|
||||||
|
authResponse.success = true;
|
||||||
|
authResponse.message = "";
|
||||||
|
authResponse.jwt = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}catch (Exception ignored){
|
||||||
|
authResponse.success = false;
|
||||||
|
authResponse.message = "UNKNOWN"; // ENG = "Username has already been taken by another user."
|
||||||
|
authResponse.jwt = "";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
authResponse.success = false;
|
authResponse.success = false;
|
||||||
|
@ -16,6 +16,7 @@ public final class Authentication {
|
|||||||
|
|
||||||
public static Account getAccountByUsernameAndPassword(String username, String password) {
|
public static Account getAccountByUsernameAndPassword(String username, String password) {
|
||||||
Account account = DatabaseHelper.getAccountByName(username);
|
Account account = DatabaseHelper.getAccountByName(username);
|
||||||
|
if (account == null) return null;
|
||||||
if(account.getPassword() != null && !account.getPassword().isEmpty()) {
|
if(account.getPassword() != null && !account.getPassword().isEmpty()) {
|
||||||
if(!verifyPassword(password, account.getPassword())) account = null;
|
if(!verifyPassword(password, account.getPassword())) account = null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user