mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-27 12:45:57 +01:00
Insert null email as DEFAULT so column default may take effect
Ugly implementation to fit into AuthMe 5.4. If email on PlayerAuth is null, do not supply NULL as the email value but use DEFAULT instead so that the default value is used if present in the column configuration.
This commit is contained in:
parent
80ab41ae5a
commit
5c40cb3b73
@ -320,22 +320,28 @@ public class MySQL implements DataSource {
|
||||
@Override
|
||||
public boolean saveAuth(PlayerAuth auth) {
|
||||
try (Connection con = getConnection()) {
|
||||
String sql;
|
||||
// TODO ljacqu 20171104: Replace with generic columns util to clean this up
|
||||
boolean useSalt = !col.SALT.isEmpty() || !StringUtils.isEmpty(auth.getPassword().getSalt());
|
||||
sql = "INSERT INTO " + tableName + "("
|
||||
boolean hasEmail = auth.getEmail() != null;
|
||||
String emailPlaceholder = hasEmail ? "?" : "DEFAULT";
|
||||
|
||||
String sql = "INSERT INTO " + tableName + "("
|
||||
+ col.NAME + "," + col.PASSWORD + "," + col.REAL_NAME
|
||||
+ "," + col.EMAIL + "," + col.REGISTRATION_DATE + "," + col.REGISTRATION_IP
|
||||
+ (useSalt ? "," + col.SALT : "")
|
||||
+ ") VALUES (?,?,?,?,?,?" + (useSalt ? ",?" : "") + ");";
|
||||
+ ") VALUES (?,?,?," + emailPlaceholder + ",?,?" + (useSalt ? ",?" : "") + ");";
|
||||
try (PreparedStatement pst = con.prepareStatement(sql)) {
|
||||
pst.setString(1, auth.getNickname());
|
||||
pst.setString(2, auth.getPassword().getHash());
|
||||
pst.setString(3, auth.getRealName());
|
||||
pst.setString(4, auth.getEmail());
|
||||
pst.setObject(5, auth.getRegistrationDate());
|
||||
pst.setString(6, auth.getRegistrationIp());
|
||||
int index = 1;
|
||||
pst.setString(index++, auth.getNickname());
|
||||
pst.setString(index++, auth.getPassword().getHash());
|
||||
pst.setString(index++, auth.getRealName());
|
||||
if (hasEmail) {
|
||||
pst.setString(index++, auth.getEmail());
|
||||
}
|
||||
pst.setObject(index++, auth.getRegistrationDate());
|
||||
pst.setString(index++, auth.getRegistrationIp());
|
||||
if (useSalt) {
|
||||
pst.setString(7, auth.getPassword().getSalt());
|
||||
pst.setString(index++, auth.getPassword().getSalt());
|
||||
}
|
||||
pst.executeUpdate();
|
||||
}
|
||||
|
@ -147,10 +147,7 @@ public class PhpBB implements EncryptionMethod {
|
||||
}
|
||||
|
||||
private static boolean phpbb_check_hash(String password, String hash) {
|
||||
if (hash.length() == 34) {
|
||||
return _hash_crypt_private(password, hash).equals(hash);
|
||||
}
|
||||
return md5(password).equals(hash);
|
||||
return _hash_crypt_private(password, hash).equals(hash);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user