Remove cache-update bungee messages, always use the player in the context to send bungee messages, minor codestyle changes
This commit is contained in:
@@ -10,8 +10,6 @@ import fr.xephi.authme.process.AsynchronousProcess;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||
import fr.xephi.authme.service.CommonService;
|
||||
import fr.xephi.authme.service.bungeecord.BungeeSender;
|
||||
import fr.xephi.authme.service.bungeecord.MessageType;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -33,9 +31,6 @@ public class AsyncChangePassword implements AsynchronousProcess {
|
||||
@Inject
|
||||
private PlayerCache playerCache;
|
||||
|
||||
@Inject
|
||||
private BungeeSender bungeeSender;
|
||||
|
||||
AsyncChangePassword() {
|
||||
}
|
||||
|
||||
@@ -46,8 +41,8 @@ public class AsyncChangePassword implements AsynchronousProcess {
|
||||
* @param oldPassword the old password used by the player
|
||||
* @param newPassword the new password chosen by the player
|
||||
*/
|
||||
public void changePassword(final Player player, String oldPassword, String newPassword) {
|
||||
final String name = player.getName().toLowerCase();
|
||||
public void changePassword(Player player, String oldPassword, String newPassword) {
|
||||
String name = player.getName().toLowerCase();
|
||||
PlayerAuth auth = playerCache.getAuth(name);
|
||||
if (passwordSecurity.comparePassword(oldPassword, auth.getPassword(), player.getName())) {
|
||||
HashedPassword hashedPassword = passwordSecurity.computeHash(newPassword, name);
|
||||
@@ -57,7 +52,8 @@ public class AsyncChangePassword implements AsynchronousProcess {
|
||||
commonService.send(player, MessageKey.ERROR);
|
||||
return;
|
||||
}
|
||||
bungeeSender.sendAuthMeBungeecordMessage(MessageType.REFRESH_PASSWORD, name);
|
||||
|
||||
// TODO: send an update when a messaging service will be implemented (PASSWORD_CHANGED)
|
||||
|
||||
playerCache.updatePlayer(auth);
|
||||
commonService.send(player, MessageKey.PASSWORD_CHANGED_SUCCESS);
|
||||
@@ -74,8 +70,8 @@ public class AsyncChangePassword implements AsynchronousProcess {
|
||||
* @param playerName the player name
|
||||
* @param newPassword the new password chosen for the player
|
||||
*/
|
||||
public void changePasswordAsAdmin(CommandSender sender, final String playerName, String newPassword) {
|
||||
final String lowerCaseName = playerName.toLowerCase();
|
||||
public void changePasswordAsAdmin(CommandSender sender, String playerName, String newPassword) {
|
||||
String lowerCaseName = playerName.toLowerCase();
|
||||
if (!(playerCache.isAuthenticated(lowerCaseName) || dataSource.isAuthAvailable(lowerCaseName))) {
|
||||
if (sender == null) {
|
||||
logger.warning("Tried to change password for user " + lowerCaseName + " but it doesn't exist!");
|
||||
@@ -87,7 +83,8 @@ public class AsyncChangePassword implements AsynchronousProcess {
|
||||
|
||||
HashedPassword hashedPassword = passwordSecurity.computeHash(newPassword, lowerCaseName);
|
||||
if (dataSource.updatePassword(lowerCaseName, hashedPassword)) {
|
||||
bungeeSender.sendAuthMeBungeecordMessage(MessageType.REFRESH_PASSWORD, lowerCaseName);
|
||||
// TODO: send an update when a messaging service will be implemented (PASSWORD_CHANGED)
|
||||
|
||||
if (sender != null) {
|
||||
commonService.send(sender, MessageKey.PASSWORD_CHANGED_SUCCESS);
|
||||
logger.info(sender.getName() + " changed password of " + lowerCaseName);
|
||||
|
||||
Reference in New Issue
Block a user