* was detected
* @throws MissingMethodException If a method was not found in the
* User class
- * @throws UserEmailMissingException If user with given email address was
- * not found in database
+ * @throws UserPasswordMismatchException If the supplied password did not
+ * match with the stored password
*/
public function doLogin (Requestable $requestInstance) {
// By default no method is selected
if (is_null($method)) {
// Then abort here
throw new UserLoginMethodException($this, self::EXCEPTION_MISSING_METHOD);
- } elseif (!method_exists("User", $method)) {
+ } elseif (!method_exists($this->getConfigInstance()->readConfig('user_class'), $method)) {
// The method is invalid!
throw new MissingMethodException(array($this, $method), self::EXCEPTION_MISSING_METHOD);
}
// Is there an instance?
if (is_null($userInstance)) {
// Get a user instance
- $userInstance = call_user_func_array(array("User", $method), array($data));
+ $userInstance = call_user_func_array(array($this->getConfigInstance()->readConfig('user_class'), $method), array($data));
+
+ // Remember this new instance in registry
+ Registry::getRegistry()->addInstance($userInstance);
} // END - if
- // If we have email login then check if a user account with that email exists!
- if (($method == "createUserByEmail") && (!$userInstance->ifEmailAddressExists())) {
- // The user account is missing!
- throw new UserEmailMissingException(array($this, $data), User::EXCEPTION_USER_EMAIL_NOT_FOUND);
+ // Is the password correct?
+ if (!$userInstance->ifPasswordHashMatches($requestInstance)) {
+ // Mismatching password
+ throw new UserPasswordMismatchException(array($this, $userInstance), User::EXCEPTION_USER_PASS_MISMATCH);
} // END - if
- // Partially finished!
- $this->partialStub("userInstance set, continue with password verification");
+ // Now do the real login. This can be cookie- or session-based login
+ // which depends on the admins setting then on the user's taste.
+ // 1) Get a login helper instance
+ $helperInstance = ObjectFactory::createObjectByConfiguredName('login_helper', array($requestInstance));
+
+ // 2) Execute the login. This will now login...
+ $helperInstance->executeLogin();
}
}