* @return void
*/
function doLogin (Requestable $requestInstance, Responseable $responseInstance);
+
+ /**
+ * Check if the implementation is correct. Only the request instance is
+ * needed as no redirect is done here.
+ *
+ * @param $requestInstance An instance of a Requestable class
+ * @return
+ */
+ function testLogin (Requestable $requestInstance);
}
// [EOF]
*/
protected final function getDatabaseEntry () {
// Is there an instance?
- if (is_null($this->getResultInstance())) {
+ if (!$this->getResultInstance() instanceof SearchableResult) {
// Throw an exception here
throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
} // END - if
// Probe on member instance
try {
// Try to instance member login class
- $loginInstance = self::createObjectByConfiguredName('user_login_class', array($requestInstance));
+ $loginInstance = self::createObjectByConfiguredName('user_login_class');
+
+ // Test login
+ $loginInstance->testLogin($requestInstance);
} catch (UnexpectedGuestAccountException $e) {
// Then try guest login
- $loginInstance = self::createObjectByConfiguredName('guest_login_class', array($requestInstance));
+ $loginInstance = self::createObjectByConfiguredName('guest_login_class');
+
+ // Test login again
+ $loginInstance->testLogin($requestInstance);
}
// Set the instance in registry for further use
// If this instance is created then the username *does* exist
try {
// Get a new instance
-
$userInstance = call_user_func_array(array($this->getConfigInstance()->getConfigEntry('user_class'), 'createMemberByUsername'), array($userName));
// Remember this user instance in our registry for later usage
const EXCEPTION_USERNAME_NOT_FOUND = 0x150;
const EXCEPTION_USER_EMAIL_NOT_FOUND = 0x151;
const EXCEPTION_USER_PASS_MISMATCH = 0x152;
+ const EXCEPTION_USER_IS_GUEST = 0x153;
/**
* Username of current user
$exists = FALSE;
// Is a previous result there?
- if (is_null($this->getResultInstance())) {
+ if (!$this->getResultInstance() instanceof SearchableResult) {
// Get a UserDatabaseWrapper instance
$wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class');
$exists = FALSE;
// Is a previous result there?
- if (is_null($this->getResultInstance())) {
+ if (!$this->getResultInstance() instanceof SearchableResult) {
// Get a UserDatabaseWrapper instance
$wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class');
$matches = FALSE;
// Is a previous result there?
- if (is_null($this->getResultInstance())) {
+ if ((!$this->getResultInstance() instanceof SearchableResult) || ($this->getResultInstance()->count() == 0)) {
// Get a UserDatabaseWrapper instance
$wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_db_wrapper_class');
throw new UsernameMissingException(array($userInstance, $userName), self::EXCEPTION_USERNAME_NOT_FOUND);
} elseif ($userInstance->isGuest() === TRUE) {
// User should not be a guest here
- throw new UnexpectedGuestAccountException(array($userInstance, $userName), self::EXCEPTION_USERNAME_NOT_FOUND);
+ throw new UnexpectedGuestAccountException(array($userInstance, $userName), self::EXCEPTION_USER_IS_GUEST);
}
// Return the instance