#358 Remove old methods on PasswordSecurity, unify hash + salt
- For encryption methods with a separate salt, the hash is useless without the salt, so hash and salt should always be persisted and retrieved together
This commit is contained in:
@@ -121,13 +121,8 @@ public class API {
|
||||
* @return true if the password is correct, false otherwise
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean checkPassword(String playerName,
|
||||
String passwordToCheck) {
|
||||
if (!isRegistered(playerName))
|
||||
return false;
|
||||
String player = playerName.toLowerCase();
|
||||
PlayerAuth auth = instance.getDataSource().getAuth(player);
|
||||
return passwordSecurity.comparePassword(passwordToCheck, auth.getHash(), playerName);
|
||||
public static boolean checkPassword(String playerName, String passwordToCheck) {
|
||||
return isRegistered(playerName) && passwordSecurity.comparePassword(passwordToCheck, playerName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -116,9 +116,11 @@ public class NewAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param playerName
|
||||
* Return whether the player is registered.
|
||||
*
|
||||
* @return true if player is registered
|
||||
* @param playerName The player name to check
|
||||
*
|
||||
* @return true if player is registered, false otherwise
|
||||
*/
|
||||
public boolean isRegistered(String playerName) {
|
||||
String player = playerName.toLowerCase();
|
||||
@@ -134,12 +136,7 @@ public class NewAPI {
|
||||
* @return true if the password is correct, false otherwise
|
||||
*/
|
||||
public boolean checkPassword(String playerName, String passwordToCheck) {
|
||||
if (!isRegistered(playerName)) {
|
||||
return false;
|
||||
}
|
||||
String player = playerName.toLowerCase();
|
||||
PlayerAuth auth = plugin.getDataSource().getAuth(player);
|
||||
return plugin.getPasswordSecurity().comparePassword(passwordToCheck, auth.getHash(), playerName);
|
||||
return isRegistered(playerName) && plugin.getPasswordSecurity().comparePassword(passwordToCheck, playerName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user