/** * 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; }
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"); } }