/** * Authenticates a given user. * @param array $formParams * @return $response */ public function login(array $formParams = array()) { // get the form object $form = new Auth_Form_Login(); // check if request is POST if (!empty($formParams)) { if ($form->isValid($formParams)) { // form is valid, get values $values = $form->getValues(); // create DbAuth model and authenticate $result = Daiquiri_Auth::getInstance()->authenticateUser($values['username'], $values['password'], $values['remember']); // redirect depending on result of authentication if ($result) { return array('status' => 'redirect'); } else { $form->setDescription('Wrong credentials provided'); return $this->getModelHelper('CRUD')->validationErrorResponse($form); } } else { return $this->getModelHelper('CRUD')->validationErrorResponse($form); } } return array('form' => $form, 'status' => 'form'); }