public function testPasswordHash() { $registry = Zend_Registry::getInstance(); $hash = $registry->config->auth->hash; $password = '******'; $expectedHash = hash('SHA256', $hash . $password); $this->object->setPassword($password, $hash); $this->assertEquals($expectedHash, $this->object->getPassword()); }
/** * Return image name, including size string by default * * @param bool $_withSize * @return string */ protected function _getImageName($_withSize = true) { $name = $this->_account->getImage(); if($_withSize) { $name .= '_' . self::USER_IMAGE_SIZE_X . 'x' . self::USER_IMAGE_SIZE_Y; } $name .= '.' . self::USER_IMAGE_TYPE; return $name; }
/** * save method * * @param void * @return void */ private function save($form) { $message = null; if ($this->_request->isPost()) { # get params $data = $this->_request->getPost(); if ($form->isValid($data)) { # check for existing email $accountExist = $this->_em->getRepository('Custom_Entity_Account')->findBy(array('email' => (string) $data['email'])); if (count($accountExist) == 0) { # register account $account = new Custom_Entity_Account; $account->setNickname($data['nickname']); $account->setFirstname($data['firstname']); $account->setLastname($data['lastname']); $account->setEmail($data['email']); $account->setPassword($data['password'], $this->_registry->config->auth->hash); $account->setCreated_at(new DateTime()); $this->_em->persist($account); $this->_em->flush(); # send to login page $this->_helper->redirector('successful', 'register', 'auth'); } else { $alert = 'Registration Failed: Email already exists'; // move to view } } # populate form $form->populate($data); } return array('form' => $form, 'alert' => empty($alert) ? null : $alert ); }