public function executeDoLogin() { if ($this->hasRequestParameter('login_user') && $this->hasRequestParameter('login_password')) { // check if the user exists $c = new Criteria(); $c->add(UserPeer::LOGIN, $this->getRequestParameter('login_user')); $user = UserPeer::doSelectOne($c); if ($user) { // check if the password is correct $password = $this->getRequestParameter('login_password'); $crypted = sha1(sfConfig::get('app_salt') . $password); if ($crypted == $user->getPassword()) { // sign in $this->getContext()->getUser()->signIn($user); // proceed to home page $this->setTemplate('index'); return; } } else { $c = new Criteria(); $c->add(EmployeePeer::EMP_NO, $this->getRequestParameter('login_user')); $user = EmployeePeer::doSelectOne($c); if ($user) { // check if the password is correct $password = $this->getRequestParameter('login_password'); $crypted = sha1(sfConfig::get('app_salt') . $password); if ($crypted == $user->getPassword()) { // sign in $this->getContext()->getUser()->signInLector($user); // proceed to home page $this->setTemplate('index'); return; } } else { $username = $this->getRequestParameter('login_user'); $dept_name = substr($username, 4, 3); $c = new Criteria(); #$c->add(VStudentLoginPeer::DEPARTMENT_NAME, $dept_name); $c->add(VStudentLoginPeer::LOGIN, $username); $user = VStudentLoginPeer::doSelectOne($c); if ($user) { // check if the password is correct $password = $this->getRequestParameter('login_password'); $crypted = sha1(sfConfig::get('app_salt') . $password); if ($crypted == $user->getPassword()) { // sign in $this->getContext()->getUser()->signInStudent($user); // proceed to home page $this->setTemplate('index'); return; } } } } // an error was found $this->getRequest()->setError('login_error_title', 'Login failed'); $this->getRequest()->setError('login_error_msg', 'Your username or password are not correct. Please try again.'); $this->getRequest()->setParameter('login_submit', null); return $this->forward('default', 'login'); } else { $this->forward('default', 'login'); } }