/** * Executes index action * * @param sfRequest $request A request object */ public function executeIndex(sfWebRequest $request) { $uid = $this->getRequestParameter('uid'); $conf = $this->getRequestParameter('conf'); $c = new Criteria(); $c->add(UsersPeer::USER_ID, $uid); $user = UsersPeer::doSelectOne($c); if (sha1($user->getSalt() . $user->getUsername()) == $conf) { $this->goodConf = true; $user->setActive('Y'); $user->save(); } else { $this->goodConf = false; } }
public function executeLogin() { $c = new Criteria(); $c->add(UsersPeer::USER_NAME, $this->getRequestParameter('login')); $c->add(UsersPeer::USER_PWD, $this->getRequestParameter('password')); $user_record = UsersPeer::doSelectOne($c); if ($user_record) { $this->getUser()->setAuthenticated(true); $c = new Criteria(); $c->add(RolePeer::ID, $user_record->getRoleId()); $user_role = RolePeer::doSelectOne($c); $this->getUser()->addCredential($user_role->getRoleName()); return $this->redirect('users'); } else { $this->getRequest()->setError('login', 'incorrect entry'); return $this->forward('security', 'index'); } }
/** * Get the associated Users object * * @param PropelPDO Optional Connection object. * @return Users The associated Users object. * @throws PropelException */ public function getUsers(PropelPDO $con = null) { if ($this->aUsers === null && $this->user_id !== null) { $c = new Criteria(UsersPeer::DATABASE_NAME); $c->add(UsersPeer::USER_ID, $this->user_id); $this->aUsers = UsersPeer::doSelectOne($c, $con); // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association. $this->aUsers->setUserInformation($this); } return $this->aUsers; }
/** * Get the associated Users object * * @param PropelPDO Optional Connection object. * @return Users The associated Users object. * @throws PropelException */ public function getUsers(PropelPDO $con = null) { if ($this->aUsers === null && $this->user_id !== null) { $c = new Criteria(UsersPeer::DATABASE_NAME); $c->add(UsersPeer::USER_ID, $this->user_id); $this->aUsers = UsersPeer::doSelectOne($c, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aUsers->addUserRidess($this); */ } return $this->aUsers; }
public function executeForgot() { if ($this->getRequest()->getMethod() != sfRequest::POST) { $this->emailSent = false; // display the form $this->getRequest()->setAttribute('referer', $this->getRequest()->getReferer()); } else { // handle the form submission $nickname = $this->getRequestParameter('nickname'); $c = new Criteria(); $c->add(UsersPeer::USERNAME, $nickname); $user = UsersPeer::doSelectOne($c); // nickname exists? if ($user) { $password = substr(md5(rand(100000, 999999)), 0, 6); $user->saltPassword($password); $user->save(); $this->emailSent = true; $this->sendPasswordMail($user->getUsername(), $user->getEmail(), $password); } else { $this->emailSent = false; } $this->getRequest()->setAttribute('referer', $this->getRequest()->getReferer()); } }