mirror of
https://github.com/exzork/GCAuth.git
synced 2024-11-27 18:01:14 +00:00
Merge pull request #5 from omg-xtao/fix
Fix the existing users can't register
This commit is contained in:
commit
517a8ea5b3
@ -30,7 +30,15 @@ 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 = DatabaseHelper.createAccountWithPassword(registerAccount.username, password);
|
Account account = Authentication.getAccountByUsernameAndPassword(registerAccount.username, "");
|
||||||
|
if (account != null) {
|
||||||
|
account.setPassword(password);
|
||||||
|
account.save();
|
||||||
|
authResponse.success = true;
|
||||||
|
authResponse.message = "";
|
||||||
|
authResponse.jwt = "";
|
||||||
|
} else {
|
||||||
|
account = DatabaseHelper.createAccountWithPassword(registerAccount.username, password);
|
||||||
if (account == null) {
|
if (account == null) {
|
||||||
authResponse.success = false;
|
authResponse.success = false;
|
||||||
authResponse.message = "USERNAME_TAKEN"; // ENG = "Username has already been taken by another user."
|
authResponse.message = "USERNAME_TAKEN"; // ENG = "Username has already been taken by another user."
|
||||||
@ -40,6 +48,7 @@ public class RegisterHandler implements HttpContextHandler {
|
|||||||
authResponse.message = "";
|
authResponse.message = "";
|
||||||
authResponse.jwt = "";
|
authResponse.jwt = "";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
authResponse.success = false;
|
authResponse.success = false;
|
||||||
authResponse.message = "PASSWORD_INVALID"; // ENG = "Password must be at least 8 characters long"
|
authResponse.message = "PASSWORD_INVALID"; // ENG = "Password must be at least 8 characters long"
|
||||||
|
Loading…
Reference in New Issue
Block a user