За последние 24 часа нас посетили 18892 программиста и 1708 роботов. Сейчас ищут 920 программистов ...

Вопрос

Тема в разделе "Прочие вопросы по PHP", создана пользователем Mixik_sp, 28 авг 2010.

  1. Mixik_sp

    Mixik_sp Активный пользователь

    С нами с:
    16 фев 2010
    Сообщения:
    24
    Симпатии:
    0
    Добрый день! Есть вопрос связанный с ZF. Клгда я запрашиваю account/registercopmlete фронт контроллер обращается не к registercopmleteAction а к совсем другому, точнее к loginAction? Я просто в ступоре, незнаю что делать.
    Вот код
    PHP:
    1.  
    2. <?php
    3.  
    4. class AccountController extends Mylib_GlobalControllerAction
    5. {    
    6.     public function registerAction()
    7.     {
    8.         $request = $this->getRequest();    
    9.        
    10.         $form_processor = new Mylib_FormProcessor_UserRegistration($this->db);
    11.         $captcha = $form_processor->generateCaptcha();
    12.         if ($request->isPost())
    13.         {          
    14.             if ($form_processor->process($request))
    15.             {
    16.                 $session = new Zend_Session_Namespace('registration');
    17.                 $session->user_id = $form_processor->user->getId();
    18.                 $this->_redirect('/account/registercomplete');
    19.             }
    20.         }        
    21.  
    22.         $this->view->captcha_id = $captcha['captcha_id'];
    23.         $this->view->imgUrl = $captcha['imgUrl'];
    24.         $this->view->imgSuffix = $captcha['imgSuffix'];
    25.         $this->view->form_processor = $form_processor;
    26.        
    27.     }
    28.  
    29.     public function registercompleteAction()
    30.     {
    31.         $session = new Zend_Session_Namespace('registration');
    32.         $user = new Mylib_DatabaseObject_User($this->db);
    33.         if (!$user->load($session->user_id))
    34.         {
    35.             $this->_forward('register', 'account');
    36.             return;
    37.         }
    38.        
    39.         $this->view->user = $user;
    40.     }
    41.  
    42.     public function loginAction()
    43.     {
    44.         $user_auth = Zend_Auth::getInstance();
    45.        
    46.         if ($user_auth->hasIdentity())
    47.         {
    48.             $this->_redirect('/account');
    49.         }
    50.        
    51.         $request = $this->getRequest();
    52.        
    53.         $redirect = $request->getParam('redirect');
    54.        
    55.         if (strlen($redirect) == 0)
    56.         {
    57.             $redirect = $request->getServer('REQUEST_URI');            
    58.         }
    59.  
    60.         if (strlen($redirect) == 0)
    61.         {
    62.             $redirect = '/account';            
    63.         }
    64.  
    65.         $errors = array();
    66.  
    67.         if ($request->isPost())
    68.         {
    69.             $username = $request->getParam('username');
    70.             $password = $request->getParam('password');
    71.  
    72.             if (strlen($username) == 0)
    73.             {
    74.                 $errors['username'] = 'Заполните поле имени';
    75.             }
    76.  
    77.             if (strlen($password) == 0)
    78.             {
    79.                 $errors['password'] = 'Заполните поле пароль';
    80.             }
    81.  
    82.             if (count($errors) == 0)
    83.             {
    84.                 $user_adapter = new Zend_Auth_Adapter_DbTable(
    85.                         $this->db,
    86.                         $tableName = 'users',
    87.                         $identityColumn = 'username',
    88.                         $credentialColumn = 'password',
    89.                         $credentialTreatment = 'md5(?)'
    90.                 );
    91.  
    92.                 $user_adapter->setIdentity($username)
    93.                              ->setCredential($password);
    94.  
    95.                 $result = $user_auth->authenticate($user_adapter);
    96.  
    97.                 if ($result->isValid())
    98.                 {
    99.                     $user_loading = $user_adapter->getResultRowObject()->user_id;
    100.                     $user = new Mylib_DatabaseObject_User($this->db);
    101.                     $user->load($user_loading);
    102.                     $user->loginSuccess();
    103.                    
    104.                     $identity = $user->createAuthIndentity();
    105.                     $user_auth->getStorage()->write($identity);
    106.                    
    107.                     $this->_redirect($redirect);
    108.                 }
    109.  
    110.                 Mylib_DatabaseObject_User::LoginFailure($username, $result->getCode());
    111.  
    112.                 $errors['username'] = 'Ваш логин был неверный';
    113.             }
    114.         }
    115.  
    116.         if (count($errors) > 0)
    117.         {
    118.             $this->view->username = $username;
    119.             $this->view->errors = $errors;
    120.             $this->view->redirect = $redirect;
    121.         }
    122.     }
    123.  
    124.     public function logoutAction()
    125.     {
    126.         $logout = Zend_Auth::getInstance();
    127.         $logout->clearIdentity();
    128.  
    129.         $this->_redirect('/account/login');
    130.     }
    131. }
    132. ?>
    133.  
     
  2. Mixik_sp

    Mixik_sp Активный пользователь

    С нами с:
    16 фев 2010
    Сообщения:
    24
    Симпатии:
    0
    Все нашел ошибку :)