Fix saveAuth method didn't save email.

This commit is contained in:
DNx5 2016-01-09 06:26:36 +07:00
parent 5187ce152a
commit 7eeabd68e7
2 changed files with 19 additions and 15 deletions

View File

@ -334,17 +334,18 @@ public class MySQL implements DataSource {
boolean useSalt = !columnSalt.isEmpty() || !StringUtils.isEmpty(auth.getPassword().getSalt());
sql = "INSERT INTO " + tableName + "("
+ columnName + "," + columnPassword + "," + columnIp + ","
+ columnLastLogin + "," + columnRealName
+ columnLastLogin + "," + columnRealName + "," + columnEmail
+ (useSalt ? "," + columnSalt : "")
+ ") VALUES (?,?,?,?,?" + (useSalt ? ",?" : "") + ");";
+ ") VALUES (?,?,?,?,?,?" + (useSalt ? ",?" : "") + ");";
pst = con.prepareStatement(sql);
pst.setString(1, auth.getNickname());
pst.setString(2, auth.getPassword().getHash());
pst.setString(3, auth.getIp());
pst.setLong(4, auth.getLastLogin());
pst.setString(5, auth.getRealName());
pst.setString(6, auth.getEmail());
if (useSalt) {
pst.setString(6, auth.getPassword().getSalt());
pst.setString(7, auth.getPassword().getSalt());
}
pst.executeUpdate();
pst.close();

View File

@ -1,5 +1,11 @@
package fr.xephi.authme.datasource;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.security.crypts.HashedPassword;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.util.StringUtils;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
@ -9,12 +15,6 @@ import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.security.crypts.HashedPassword;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.util.StringUtils;
/**
*/
public class SQLite implements DataSource {
@ -41,7 +41,7 @@ public class SQLite implements DataSource {
* Constructor for SQLite.
*
* @throws ClassNotFoundException Exception
* @throws SQLException Exception
* @throws SQLException Exception
*/
public SQLite() throws ClassNotFoundException, SQLException {
this.database = Settings.getMySQLDatabase;
@ -219,23 +219,26 @@ public class SQLite implements DataSource {
+ "is not set in the config!");
}
pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword +
"," + columnIp + "," + columnLastLogin + "," + columnRealName + ") VALUES (?,?,?,?,?);");
"," + columnIp + "," + columnLastLogin + "," + columnRealName + "," + columnEmail +
") VALUES (?,?,?,?,?,?);");
pst.setString(1, auth.getNickname());
pst.setString(2, password.getHash());
pst.setString(3, auth.getIp());
pst.setLong(4, auth.getLastLogin());
pst.setString(5, auth.getRealName());
pst.setString(6, auth.getEmail());
pst.executeUpdate();
} else {
pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + ","
+ columnIp + "," + columnLastLogin + "," + columnSalt + "," + columnRealName
+ ") VALUES (?,?,?,?,?,?);");
+ columnIp + "," + columnLastLogin + "," + columnRealName + "," + columnEmail + "," + columnSalt
+ ") VALUES (?,?,?,?,?,?,?);");
pst.setString(1, auth.getNickname());
pst.setString(2, password.getHash());
pst.setString(3, auth.getIp());
pst.setLong(4, auth.getLastLogin());
pst.setString(5, password.getSalt());
pst.setString(6, auth.getRealName());
pst.setString(5, auth.getRealName());
pst.setString(6, auth.getEmail());
pst.setString(7, password.getSalt());
pst.executeUpdate();
}
} catch (SQLException ex) {