#1347 Adapt tests for new change password architecture
This commit is contained in:
+3
-21
@@ -1,11 +1,7 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.data.auth.PlayerCache;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.process.Management;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.service.BukkitService;
|
||||
import fr.xephi.authme.service.CommonService;
|
||||
import fr.xephi.authme.service.ValidationService;
|
||||
import fr.xephi.authme.service.ValidationService.ValidationResult;
|
||||
@@ -19,18 +15,6 @@ import java.util.List;
|
||||
*/
|
||||
public class ChangePasswordAdminCommand implements ExecutableCommand {
|
||||
|
||||
@Inject
|
||||
private PasswordSecurity passwordSecurity;
|
||||
|
||||
@Inject
|
||||
private PlayerCache playerCache;
|
||||
|
||||
@Inject
|
||||
private DataSource dataSource;
|
||||
|
||||
@Inject
|
||||
private BukkitService bukkitService;
|
||||
|
||||
@Inject
|
||||
private ValidationService validationService;
|
||||
|
||||
@@ -41,7 +25,7 @@ public class ChangePasswordAdminCommand implements ExecutableCommand {
|
||||
private Management management;
|
||||
|
||||
@Override
|
||||
public void executeCommand(final CommandSender sender, List<String> arguments) {
|
||||
public void executeCommand(CommandSender sender, List<String> arguments) {
|
||||
// Get the player and password
|
||||
final String playerName = arguments.get(0);
|
||||
final String playerPass = arguments.get(1);
|
||||
@@ -50,10 +34,8 @@ public class ChangePasswordAdminCommand implements ExecutableCommand {
|
||||
ValidationResult validationResult = validationService.validatePassword(playerPass, playerName);
|
||||
if (validationResult.hasError()) {
|
||||
commonService.send(sender, validationResult.getMessageKey(), validationResult.getArgs());
|
||||
return;
|
||||
} else {
|
||||
management.performPasswordChangeAsAdmin(sender, playerName, playerPass);
|
||||
}
|
||||
|
||||
// Set the password
|
||||
management.performPasswordChangeAsAdmin(sender, playerName, playerPass);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public class AsyncChangePassword implements AsynchronousProcess {
|
||||
public void changePasswordAsAdmin(CommandSender sender, final String playerName, String newPassword) {
|
||||
final String lowerCaseName = playerName.toLowerCase();
|
||||
if (!(playerCache.isAuthenticated(lowerCaseName) || dataSource.isAuthAvailable(lowerCaseName))) {
|
||||
if(sender == null) {
|
||||
if (sender == null) {
|
||||
ConsoleLogger.warning("Tried to change password for user " + lowerCaseName + " but it doesn't exist!");
|
||||
} else {
|
||||
commonService.send(sender, MessageKey.UNKNOWN_USER);
|
||||
@@ -78,14 +78,14 @@ public class AsyncChangePassword implements AsynchronousProcess {
|
||||
|
||||
HashedPassword hashedPassword = passwordSecurity.computeHash(newPassword, lowerCaseName);
|
||||
if (dataSource.updatePassword(lowerCaseName, hashedPassword)) {
|
||||
if(sender != null) {
|
||||
if (sender != null) {
|
||||
commonService.send(sender, MessageKey.PASSWORD_CHANGED_SUCCESS);
|
||||
ConsoleLogger.info(sender.getName() + " changed password of " + lowerCaseName);
|
||||
} else {
|
||||
ConsoleLogger.info("Changed password of " + lowerCaseName);
|
||||
}
|
||||
} else {
|
||||
if(sender != null) {
|
||||
if (sender != null) {
|
||||
commonService.send(sender, MessageKey.ERROR);
|
||||
}
|
||||
ConsoleLogger.warning("An error occurred while changing password for user " + lowerCaseName + "!");
|
||||
|
||||
Reference in New Issue
Block a user