mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2025-01-27 10:01:34 +01:00
parent
8f446fa6af
commit
8b71f964da
@ -62,7 +62,7 @@ public class ChangePasswordCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new ChangePasswordTask(plugin, player, args[0]));
|
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new ChangePasswordTask(plugin, player, args[0], args[1]));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,12 +15,14 @@ public class ChangePasswordTask implements Runnable {
|
|||||||
|
|
||||||
private final AuthMe plugin;
|
private final AuthMe plugin;
|
||||||
private final Player player;
|
private final Player player;
|
||||||
private String password;
|
private final String oldPassword;
|
||||||
|
private final String newPassword;
|
||||||
|
|
||||||
public ChangePasswordTask(AuthMe plugin, Player player, String password) {
|
public ChangePasswordTask(AuthMe plugin, Player player, String oldPassword, String newPassword) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.password = password;
|
this.oldPassword = oldPassword;
|
||||||
|
this.newPassword = newPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -28,13 +30,15 @@ public class ChangePasswordTask implements Runnable {
|
|||||||
Messages m = Messages.getInstance();
|
Messages m = Messages.getInstance();
|
||||||
try {
|
try {
|
||||||
String name = player.getName().toLowerCase();
|
String name = player.getName().toLowerCase();
|
||||||
String hashnew = PasswordSecurity.getHash(Settings.getPasswordHash, password, name);
|
String hashnew = PasswordSecurity.getHash(Settings.getPasswordHash, newPassword, name);
|
||||||
if (PasswordSecurity.comparePasswordWithHash(password, PlayerCache.getInstance().getAuth(name).getHash(), player.getName())) {
|
PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
|
||||||
PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
|
if (PasswordSecurity.comparePasswordWithHash(oldPassword, auth.getHash(), player.getName())) {
|
||||||
auth.setHash(hashnew);
|
auth.setHash(hashnew);
|
||||||
if (PasswordSecurity.userSalt.containsKey(name) && PasswordSecurity.userSalt.get(name) != null)
|
if (PasswordSecurity.userSalt.containsKey(name) && PasswordSecurity.userSalt.get(name) != null) {
|
||||||
auth.setSalt(PasswordSecurity.userSalt.get(name));
|
auth.setSalt(PasswordSecurity.userSalt.get(name));
|
||||||
else auth.setSalt("");
|
} else {
|
||||||
|
auth.setSalt("");
|
||||||
|
}
|
||||||
if (!plugin.database.updatePassword(auth)) {
|
if (!plugin.database.updatePassword(auth)) {
|
||||||
m.send(player, "error");
|
m.send(player, "error");
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user