Exemplo n.º 1
0
 /**
  * Get and configure the auth adapter
  *
  * @param  array $value Array of user credentials
  * @return Zend_Auth_Adapter_DbTable
  */
 public function getAuthAdapter($values)
 {
     if (null === $this->_authAdapter) {
         $salt = RFLib_Config::getPasswordSalt();
         $authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Db_Table_Abstract::getDefaultAdapter(), 'user', 'email', 'password', 'MD5(CONCAT(?,"' . $salt . '"))');
         $this->setAuthAdapter($authAdapter);
         $this->_authAdapter->setIdentity($values['email']);
         $this->_authAdapter->setCredential($values['password']);
     }
     return $this->_authAdapter;
 }
Exemplo n.º 2
0
 /**
  * Save the data to db
  *
  * @param  Zend_Form $form The Validator
  * @param  array     $info The data
  * @param  array     $defaults Default values
  * @return false|int
  */
 protected function _save($form, $info, $defaults = array())
 {
     if (!$form->isValid($info)) {
         return false;
     }
     // get filtered values
     $data = $form->getValues();
     // password hashing
     if (array_key_exists(self::PASSWORD_FIELD, $data) && '' == $data[self::PASSWORD_FIELD]) {
         unset($data[self::PASSWORD_FIELD]);
     } elseif (isset($data[self::PASSWORD_FIELD])) {
         $salt = RFLib_Config::getPasswordSalt();
         $data[self::PASSWORD_FIELD] = md5($data[self::PASSWORD_FIELD] . $salt);
     }
     // apply any defaults
     foreach ($defaults as $col => $value) {
         $data[$col] = $value;
     }
     $user = array_key_exists('id', $data) ? $this->findById($data['id']) : null;
     return $this->getTable('User')->saveRow($data, $user);
 }