示例#1
0
 public function executeDologin(sfWebRequest $request)
 {
     $form = new LoginForm();
     $form->bind($this->getRequestParameter('credentials'));
     if ($form->isValid()) {
         $credentials = $request->getParameter('credentials');
         $login = $credentials['login'];
         $user = UserTable::getUserFromLogin($login);
         ## Store array of allowed sectionIds that can be accessed!
         $sectionIdsArray = Doctrine_Core::getTable('Program')->getProgramsByDepartmentId($user->getDepartmentId());
         // set the session correctly
         $this->getUser()->setAuthenticated(true);
         $this->getUser()->setAttribute('userId', $user->getId());
         $this->getUser()->setAttribute('departmentId', $user->getDepartmentId());
         $this->getUser()->setAttribute('departmentName', $user->getDepartment());
         $this->getUser()->setAttribute('sectionIds', array_keys($sectionIdsArray));
         $this->getUser()->setAttribute('credential', $user->getPrivilege());
         ##Do Logging!!
         $newLog = new AuditLog();
         $action = 'User has logged into Student Record Management System';
         $newLog->addNewLogInfo($this->getUser()->getAttribute('userId'), $action);
         $this->getUser()->setFlash('notice', 'Welcome' . ' ' . $user->getFirstName());
         //$this->redirect('filter/show?id='.$user->getId());
         $this->redirect('programsection/index');
     } else {
         // give the form again
         $this->form = $form;
         $this->setTemplate('login');
     }
 }
示例#2
0
 protected function doClean($password)
 {
     $login = $_POST['credentials']['login'];
     $user = UserTable::getUserFromLogin($login);
     if (!$user->checkPassword($password)) {
         throw new sfValidatorError($this, 'invalid');
     }
     return $password;
 }
示例#3
0
 public function executeDologin(sfWebRequest $request)
 {
     $form = new LoginForm();
     $form->bind($this->getRequestParameter('credentials'));
     if ($form->isValid()) {
         $credentials = $request->getParameter('credentials');
         $login = $credentials['login'];
         $user = UserTable::getUserFromLogin($login);
         // set the session correctly
         $this->getUser()->setAuthenticated(true);
         $this->getUser()->setAttribute('user_id', $user->getId());
         $this->getUser()->setFlash('notice', 'Welcome' . ' ' . $user->getLogin());
         $this->redirect('user/show?id=' . $user->getId());
     } else {
         // give the form again
         $this->form = $form;
         $this->setTemplate('login');
     }
 }