Do not register users and connect users without passwords when authentication is not activated.

This commit is contained in:
Me Car 2016-01-11 10:17:30 +09:00
parent 4eb9719769
commit 3bc8f4bec2

View file

@ -75,6 +75,9 @@ public class Session {
}
public String registerUser(String userName, String password, String email) throws MageException {
if (!ConfigSettings.getInstance().isAuthenticationActivated()) {
return "Registration is disabled by the server config.";
}
synchronized(AuthorizedUserRepository.instance) {
String returnMessage = validateUserName(userName);
if (returnMessage != null) {
@ -140,10 +143,13 @@ public class Session {
public String connectUserHandling(String userName, String password) throws MageException {
this.isAdmin = false;
if (ConfigSettings.getInstance().isAuthenticationActivated()) {
AuthorizedUser authorizedUser = AuthorizedUserRepository.instance.get(userName);
if (authorizedUser == null || !authorizedUser.doCredentialsMatch(userName, password)) {
return "Wrong username or password";
}
}
User user = UserManager.getInstance().createUser(userName, host);
boolean reconnect = false;