private $email = "";
// Exceptions
- const EXCEPTION_USERNAME_NOT_FOUND = 0xd00;
- const EXCEPTION_USER_EMAIL_NOT_FOUND = 0xd01;
+ const EXCEPTION_USERNAME_NOT_FOUND = 0x060;
+ const EXCEPTION_USER_EMAIL_NOT_FOUND = 0x061;
+ const EXCEPTION_USER_PASS_MISMATCH = 0x062;
/**
* Protected constructor
* @return $exists Wether the username exists
*/
public function ifUsernameExists () {
- // By default the username does exist
- $exists = true;
+ // By default the username does not exist
+ $exists = false;
// Get a UserDatabaseWrapper instance
- $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper');
+ $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class');
// Create a search criteria
- $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria');
+ $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
// Add the username as a criteria and set limit to one entry
$criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUsername());
$result = $wrapperInstance->doSelectByCriteria($criteriaInstance);
// Search for it
- if (!$result->next()) {
- // Entry not found
- $exists = false;
+ if ($result->next()) {
+ // Entry found
+ $exists = true;
} // END - if
// Return the status
* @return $exists Wether the email exists
*/
public function ifEmailAddressExists () {
- // By default the username does exist
- $exists = true;
+ // By default the email does not exist
+ $exists = false;
// Get a UserDatabaseWrapper instance
- $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper');
+ $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class');
// Create a search criteria
- $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria');
+ $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
// Add the username as a criteria and set limit to one entry
$criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_EMAIL, $this->getEmail());
$result = $wrapperInstance->doSelectByCriteria($criteriaInstance);
// Search for it
- if (!$result->next()) {
- // Entry not found
- $exists = false;
+ if ($result->next()) {
+ // Entry found
+ $exists = true;
} // END - if
// Return the status
return $exists;
}
+
+ /**
+ * Checks if the supplied password hash in request matches with the stored
+ * in database.
+ *
+ * @param $requestInstance A requestable class instance
+ * @return $matches Wether the supplied password hash matches
+ */
+ public function ifPasswordHashMatches (Requestable $requestInstance) {
+ // By default nothing matches... ;)
+ $matches = false;
+
+ // Get a UserDatabaseWrapper instance
+ $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class');
+
+ // Create a search criteria
+ $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+ // Add the username as a criteria and set limit to one entry
+ $criteriaInstance->addCriteria(UserDatabaseWrapper::DB_COLUMN_USERNAME, $this->getUserName());
+ $criteriaInstance->setLimit(1);
+
+ // Get a search result
+ $result = $wrapperInstance->doSelectByCriteria($criteriaInstance);
+
+ // Search for it
+ if ($result->next()) {
+ // Get the current entry (can only be one!)
+ $entry = $result->current();
+
+ // So does the hashes match?
+ $matches = ($requestInstance->getRequestElement('pass_hash') === $entry['pass_hash']);
+ } // END - if
+
+ // Return the status
+ return $matches;
+ }
+
+ /**
+ * Adds data for later complete update
+ *
+ * @param $column Column we want to update
+ * @param $value New value to store in database
+ * @return void
+ */
+ public function addUpdateData ($column, $value) {
+ $this->partialStub("Column={$column}, value={$value}");
+ }
}
// [EOF]