/**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = PcPasswordResetTokenPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setUserId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setToken($arr[$keys[1]]);
     }
 }
Exemplo n.º 2
0
 public function executePasswordReset(sfWebRequest $request)
 {
     $token = '';
     if ($request->getParameter('t')) {
         $token = $request->getParameter('t');
     } else {
         $param = $request->getParameter('passwordReset');
         $token = $param['t'];
     }
     $token = trim($token);
     // if the user is authenticated, they shouldn't get here
     PcUtils::redirectLoggedInUser($this->getUser(), $this);
     // Check the token is valid
     $c = new Criteria();
     $c->add(PcPasswordResetTokenPeer::TOKEN, $token, Criteria::EQUAL);
     $entry = PcPasswordResetTokenPeer::doSelectOne($c);
     if (!is_object($entry)) {
         // the token is not valid
         PcWatchdog::alert('Invalid Password Reset Token', 'This is the token ' . $token);
         $this->forward('customAuth', 'passwordResetInvalidToken');
     }
     $this->form = new PasswordResetForm(array('t' => $token));
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter('passwordReset'));
         if ($this->form->isValid()) {
             $fields = $request->getParameter('passwordReset');
             $user = CustomAuth::resetPassword($token, $fields['password1']);
             $this->redirect('/' . sfConfig::get('app_accountApp_frontController'));
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Gets a single PcPasswordResetToken object, which is related to this object by a one-to-one relationship.
  *
  * @param      PropelPDO $con
  * @return     PcPasswordResetToken
  * @throws     PropelException
  */
 public function getPcPasswordResetToken(PropelPDO $con = null)
 {
     if ($this->singlePcPasswordResetToken === null && !$this->isNew()) {
         $this->singlePcPasswordResetToken = PcPasswordResetTokenPeer::retrieveByPK($this->id, $con);
     }
     return $this->singlePcPasswordResetToken;
 }
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(PcPasswordResetTokenPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(PcPasswordResetTokenPeer::DATABASE_NAME);
         $criteria->add(PcPasswordResetTokenPeer::USER_ID, $pks, Criteria::IN);
         $objs = PcPasswordResetTokenPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Exemplo n.º 5
0
 /**
  * Takes care after the user resets their password succcessfully
  *
  * @param string $token
  * @param string $password - the new password to set (plain password)
  * @return PcUser - the user who has reset their own password
  */
 public static function resetPassword($token, $password)
 {
     $c = new Criteria();
     $c->add(PcPasswordResetTokenPeer::TOKEN, $token, Criteria::EQUAL);
     $tokenEntry = PcPasswordResetTokenPeer::doSelectOne($c);
     $userId = $tokenEntry->getUserId();
     $tokenEntry->delete();
     $sfContext = sfContext::getInstance();
     $user = PcUserPeer::retrieveByPk($userId);
     $user->setPassword($password);
     $user->save();
     self::login($sfContext->getUser(), $user);
     sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent('userSetPassword', 'user.set_password', array('user' => $user, 'plainPassword' => $password)));
     return $user;
 }