/**
  * @param int $userId
  * @param string $token
  * @return Token
  */
 public static function createToken($userId, $token)
 {
     $newToken = new Token();
     $newToken->setUserId($userId);
     $newToken->setToken($token);
     return $newToken;
 }
 /**
  * @param integer $user_id
  * @return Token
  */
 public function createAutologinToken($user_id)
 {
     $token = new Token();
     $token->setUserId($user_id);
     $token->setAction(Token::$ACTION_AUTOLOGIN);
     return $token;
 }
 public function getTokenUserCloud($user, $cloud)
 {
     $token = new Token();
     $token->setUserId($user);
     $token->setCloudspaceName($cloud);
     try {
         $toReturn = current($this->dao->search($token));
     } catch (EyeResultNotFoundException $e) {
     }
     return $toReturn;
 }
Exemple #4
0
 public function executeSendPassword(sfWebRequest $request)
 {
     // try to find the user by the given E-Mail-Address
     $user = Doctrine::getTable('User')->findOneByEmail($request->getParameter('email'));
     if ($user) {
         // delete all previous recovery tokens
         Doctrine_Query::create()->delete('Token t')->where('t.user_id=? AND action=?', array($user->getId(), Token::$ACTION_RECOVER))->execute();
         // generate recover token
         $token = new Token();
         $token->setUserId($user->getId());
         $token->setAction(Token::$ACTION_RECOVER);
         $token->save();
         // sending user email
         $html = $this->getPartial('recoverEmail', array('user' => $user, 'token' => $token));
         $subject = sfContext::getInstance()->getI18N()->__('Your TimeHive password');
         MailSender::createInstance()->send($user['email'], $subject, $html);
         $this->getUser()->setFlash('send_pwd_failure', $this->getContext()->getI18N()->__('An email with instructions to choose a new password has been sent to you.'));
         $this->redirect('login/index');
     } else {
         $this->getUser()->setFlash('send_pwd_failure', $this->getContext()->getI18N()->__('There is no such e-mail address in the our database!'));
         $this->redirect('login/index');
     }
 }