/** * @param \Likedimion\Database\Entity\Account $account * @param \DateTime $endDate * @return Token */ public function generateToken(Account $account, \DateTime $endDate) { $tokenValue = $account->getLogin() . "_" . $account->getPassword() . "_" . rand(0, 99999999999); $token = new Token(); $token->setValue(md5($tokenValue)); $token->setEndDate($endDate); $this->getRepository()->save($token); return $token; }
/** * @param string $email * @param string $password * @param string $confirmPassword * @throws \Likedimion\Exception\AccountServiceException * @internal param string $login * @return bool */ public function registration($email, $password, $confirmPassword = "") { if ($password == $confirmPassword) { $account = new Account(); $account->setLogin($email); $account->setPassword($password); $account->setEmail($email); try { $findAccount = $this->getRepository()->findByLogin($email); $findAccountEmail = $this->getRepository()->findByEmail($email); throw new AccountServiceException("login_already_exists"); } catch (EntityNotFoundException $e) { $this->getRepository()->save($account); return true; } } else { throw new AccountServiceException("passwords_not_confirm"); } }
/** * {@inheritDoc} */ public function validateAccount() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'validateAccount', array()); return parent::validateAccount(); }