Exemplo n.º 1
0
 /**
  * Filter the query by a related \Models\Identity object
  *
  * @param \Models\Identity|ObjectCollection $identity the related object to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildUserQuery The current query, for fluid interface
  */
 public function filterByIdentity($identity, $comparison = null)
 {
     if ($identity instanceof \Models\Identity) {
         return $this->addUsingAlias(UserTableMap::COL_ID, $identity->getUserId(), $comparison);
     } elseif ($identity instanceof ObjectCollection) {
         return $this->useIdentityQuery()->filterByPrimaryKeys($identity->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByIdentity() only accepts arguments of type \\Models\\Identity or Collection');
     }
 }
Exemplo n.º 2
0
 /**
  * @param ChildIdentity $identity The ChildIdentity object to add.
  */
 protected function doAddIdentity(ChildIdentity $identity)
 {
     $this->collIdentities[] = $identity;
     $identity->setUser($this);
 }
Exemplo n.º 3
0
 /**
  * Exclude object from result
  *
  * @param   ChildIdentity $identity Object to remove from the list of results
  *
  * @return $this|ChildIdentityQuery The current query, for fluid interface
  */
 public function prune($identity = null)
 {
     if ($identity) {
         $this->addUsingAlias(IdentityTableMap::COL_ID, $identity->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
Exemplo n.º 4
0
 protected function signIn()
 {
     if (isset($_POST["username"]) && isset($_POST["password"])) {
         $user = UserQuery::create()->findOneByUsername($_POST["username"]);
         if (!$user) {
             $this->sendFlashMessage("You have not been signed in. User does not exist.", "error");
         } else {
             if ($user->getDeletedAt()) {
                 $this->sendFlashMessage("Your account was deleted on " . $user->getDeletedAt("j M o") . '. <a class="link" href="/user/' . $user->getUsername() . '/send-restore-account-email">Send restore link?</a>', "error");
                 $this->redirect("/404");
             } else {
                 if ($user->checkPassword($_POST["password"])) {
                     $_SESSION["userId"] = $user->getId();
                     if (isset($_POST["rememberMe"])) {
                         if (isset($_COOKIE["identityId"])) {
                             $identity = IdentityQuery::create()->filterById($_COOKIE["identityId"])->delete();
                         }
                         $token = generateRandomString(32);
                         $identity = new Identity();
                         $identity->setToken($token)->setUser($user)->save();
                         setcookie("identityId", $identity->getId(), time() + 86400 * 120);
                         setcookie("identityToken", $token, time() + 86400 * 120);
                     }
                 } else {
                     $this->sendFlashMessage("You have not been signed in. You entered wrong password.", "error");
                 }
             }
         }
         $this->redirect($this->data["referersURI"]);
     } else {
         setHTTPStatusCode("400");
     }
 }