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 Role object * * @param PropelPDO Optional Connection object. * @return Role The associated Role object. * @throws PropelException */ public function getRole(PropelPDO $con = null) { if ($this->aRole === null && $this->role_id !== null) { $c = new Criteria(RolePeer::DATABASE_NAME); $c->add(RolePeer::ID, $this->role_id); $this->aRole = RolePeer::doSelectOne($c, $con); // Because this foreign key represents a one-to-one relationship, we will create a bi-directional association. $this->aRole->setTeamNote($this); } return $this->aRole; }
/** * Get the associated Role object * * @param PropelPDO Optional Connection object. * @return Role The associated Role object. * @throws PropelException */ public function getRole(PropelPDO $con = null) { if ($this->aRole === null && $this->role_id !== null) { $c = new Criteria(RolePeer::DATABASE_NAME); $c->add(RolePeer::ID, $this->role_id); $this->aRole = RolePeer::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->aRole->addUsers($this); */ } return $this->aRole; }