import mir.module.AbstractModule;
import mir.module.ModuleExc;
import mir.module.ModuleFailure;
-import mir.storage.StorageObject;
import mir.util.JDBCStringRoutines;
import mircoders.entity.EntityUsers;
import mircoders.global.MirGlobal;
+import mircoders.storage.DatabaseUsers;
/*
{
static LoggerWrapper logger = new LoggerWrapper("Module.Users");
- public ModuleUsers(StorageObject aStorage)
- {
- if (aStorage == null)
- logger.warn("ModuleUsers(): StorageObject was null!");
-
- theStorage = aStorage;
+ public ModuleUsers() {
+ super(DatabaseUsers.getInstance());
}
/**
* @param password The password
* @return The authenticated user, or <code>null</code> if the user
* doesn't exist, or the supplied password is invalid.
- * @throws ModuleException
+ * @throws ModuleExc
*/
public EntityUsers getUserForLogin(String user, String password) throws ModuleExc, ModuleFailure {
try {
String whereString =
"login='" + JDBCStringRoutines.escapeStringLiteral(user) + "' " +
- "and password='" + JDBCStringRoutines.escapeStringLiteral(
- MirGlobal.localizer().adminInterface().makePasswordDigest(password)) +
- "' " +
+ "and (" +
+ " password='" + JDBCStringRoutines.escapeStringLiteral(MirGlobal.localizer().adminInterface().makePasswordDigest(password)) + "'" +
+ " or password='" + JDBCStringRoutines.escapeStringLiteral(password) + "'" +
+ " )" +
"and is_admin='1'";
EntityList userList = getByWhereClause(whereString, -1);
- if (userList != null && userList.getCount() == 1) {
+ if (userList != null && userList.size() == 1) {
EntityUsers result = (EntityUsers) userList.elementAt(0);
- if (result.getValue("is_disabled") == null ||
- result.getValue("is_disabled").equals("0"))
+ if (result.getFieldValue("is_disabled") == null ||
+ result.getFieldValue("is_disabled").equals("0"))
return result;
-
}
return null;
public boolean checkUserPassword(EntityUsers aUser, String aPassword) throws ModuleExc, ModuleFailure {
try {
- return aUser.getValue("password").equals(MirGlobal.localizer().adminInterface().makePasswordDigest(aPassword));
+ return aUser.getFieldValue("password").equals(MirGlobal.localizer().adminInterface().makePasswordDigest(aPassword));
}
catch (Throwable t) {
throw new ModuleFailure(t);
}
}
- private Map digestPassword(Map aValues) throws ModuleExc, ModuleFailure {
+ private Map digestPassword(Map aValues) throws ModuleFailure {
Map result = aValues;
try {
}
}
- /**
- *
- * @param theValues
- * @return
- * @throws ModuleExc
- * @throws ModuleFailure
- */
public String set (Map theValues) throws ModuleExc, ModuleFailure {
try {
return super.set(digestPassword(theValues));
try {
String sql = "update webdb_users set lastlogin=now() where id = " + aUser.getId();
- theStorage.executeUpdate(sql);
+ database.executeUpdate(sql);
}
catch (Throwable t) {
- throw new ModuleFailure(t);
+// no propagation of this error for now, to allow mir to still function
+// with older db schemas
+// throw new ModuleFailure(t);
}
}
}
\ No newline at end of file