2013-07-29 5 views
1

인증 구성 요소가 작년에 잘 작동했습니다. 나는 약 2 시간 전에 내 사이트에 로그인하여 하나의 사소한 변화를 만들었습니다. 나는 그 두 시간 동안 내렸고 약 30 분 전에 돌아 왔으므로 나는 내 사이트에 로그인 할 수 없었다. 오류 메시지가 사용자 이름/암호 조합이 잘못되었다고 말합니다. 어떻게 든 값이 내 데이터베이스에서 변경되었거나 브라우저가 이전 암호를 자동 저장 했으므로 데이터베이스의 암호를 적절한 md5 해시 값으로 업데이트했는지 확인하고 브라우저에서 다시 시도했습니다. 여전히 효과가 없었습니다.CakePHP 인증 로그인 작동 중지

내가 this post에서 그렇게 제안했기 때문에 캐시를 비운다.하지만 이것도 작동하지 않았다. (또한이 질문의 포스터를 도왔다). 뷰 파일을 변경하지 않았기 때문에 뷰어 파일에 데이터베이스 연결을 깨뜨린 사람의 해결책이 적용되지 않습니다. 또한 사용자 모델이나 앱 컨트롤러를 변경하지 않았습니다. 이전에 내가 변경된 유일한 것은 UsersController online() 액션을 편집 한 것입니다. 나는 그것을 뒤로 바꿨다. 사실, 나는 내 사이트 백업 유틸리티에 들어가서 모든 컨트롤러와 모델 파일을 2 일 전에 모든 것이 작동 할 때의 최신 백업으로 복원했다. 여전히 영향을 미치지 않습니다.

내가 등록한 계정에 로그인 할 수 없습니다. 심지어 데이터베이스의 암호 중 하나를 unhashed 및 해당 계정으로 로그인 시도했지만 그 중 하나를 작동하지 않았다.

의 AppController

//I HAVE NOT CHANGED THIS IN SEVERAL MONTHS 

public $helpers = array('Form', 'Html', 'Custom', 'Time', 'Js', 'Cache'); 
public $components = array('CustomPage', 'Session', 'CustomUser', 
    'Auth' => array(
     'autoRedirect' => false, 
     'loginAction' => array('controller' => 'users', 'action' => 'login', 'prefix' => false, 'admin' => false, 'moderate' => false), 
     'loginRedirect' => array('prefix' => false, 'admin' => false, 'moderate' => false, 'controller' => 'account', 'action' => 'index'), 
     'logoutRedirect' => array('controller' => 'index', 'prefix' => false, 'admin' => false, 'moderate' => false), 
     'authError' => "You can't access that page", 
     'authorize' => array('Controller') 
    ) 
); // components 

public function isAuthorized($user) { 
    return true; 
} 

UsersController 내 사용자 모델은 사용자를 인증하는 표준 "사용자 이름"과 "암호"열을 사용

// DID NOT CHANGE FOLLOWING ACTION 

public function login() { 
    if ($this->Session->read('Auth.User')) { 
     $this->Session->setFlash('You are already logged in'); 
     $this->redirect(array('controller' => 'account', 'action' => 'index')); 
    } 

    $this->layout = "simple"; 
    $this->set('title_for_layout', 'Login'); 

    if ($this->request->is('post')) { 
     $this->User->UsersOnline->deleteAll(array('UsersOnline.session' => $this->viewVars['session_session']), false); 

     if ($this->Auth->login()) { // check user is logged in 
      $this->User->id = $this->Auth->user('id'); 
      $this->User->saveField('last_login', date(Configure::read('Site.date_format'))); // save login time 
      $this->redirect($this->Auth->redirect()); // redirect to default place 
     } else { 
      $this->Session->setFlash('Your username/password combination was incorrect'); 
     } 
    } 
} // end login 


// THE FOLLOWING ACTION WAS THE ONLY THING 
// THAT WAS CHANGED BUT IT IS NOW BACK TO ORIGINAL VERSION 

public function online() { 
    $page_id = $this->viewVars['page_id']; 
    $link = $this->viewVars['link']; 

    // CONTAIN 
    $this->User->UsersOnline->contain(array(
     'User' => array(
      'fields' => array(
       'User.username', 'User.online' 
      ), 
      'Avatar' => array(
       'fields' => array(
        'Avatar.file' 
       ) 
      ) 
     ) 
    )); 

    if($page_id){ 
     $this->set('users', $this->paginate($this->User->UsersOnline, array('UsersOnline.page_id' => $page_id))); 
     $this->set('title_for_layout', 'Fans Online'); 
    } 
    else{ 
     $this->set('title_for_layout', 'Users Online'); 
     $this->set('users', $this->paginate($this->User->UsersOnline)); 
     $this->layout = "default"; 
    }  
} // end online action 

.

내 UserController 로그인() 액션에 다음 코드를 추가 한 올바른 결과가 인쇄됩니다

...

$password = md5($this->request->data['User']['password']); 

print_r(
    $this->User->find('first', 
     array(
      'User.username' => $this->request->data['User']['username'], 
      'User.password' => $password 
     ) 
    ) 
); 

는 다시, 나는 2 일에서 자신의 상태로 모든 컨트롤러와 모델 파일을 복원 한 전 그래서이 문제의 원인이 무엇인지 전혀 모릅니다.

편집 1 : 이제 안전을 기하기 위해 모든 내보기 파일을 이번 주말의 최신 백업 버전으로 되돌릴 수있었습니다. 이것은 문제를 해결하지 못했습니다.

편집 2 :$this->Auth->login을 디버깅하면 결과가 비어 있습니다. 아무것도 바뀌지 않으면 갑자기 이것이 왜 비어 있지 않습니까?

편집 3 :. 내 UsersController 레지스터() 액션을 적절하게 자동으로 새 사용자를 만들고에 해당 사용자를 기록

UsersController

public function register() { 
    if($this->Session->read('Auth.User')) { 
     $this->Session->setFlash('You are already registered'); 
     $this->redirect(array('controller' => 'account', 'action' => 'index')); 
    } 

    $this->layout = "simple"; 
    $this->set('title_for_layout', 'Register'); 
    if ($this->request->is('post')) { 
      $this->User->create(); 

      if ($this->User->save($this->request->data)) { 
       $id = $this->User->id; 
       $this->request->data['User'] = array_merge($this->request->data['User'], array('id' => $id)); 

       if($this->Auth->login($this->request->data['User'])){ 
        $this->Session->setFlash(__('Your account has successfully been created and you have logged in')); 
        $this->redirect(array('controller' => 'account', 'action' => 'index')); 
       } // end if account created and successful log in 
       else{ 
        $this->Session->setFlash(__('Your account has successfully been created but you cannot log in')); 
       } // end else if account created but not logged in 
      } else { 
       $this->Session->setFlash(__('Your account could not be created. Please, try again.')); 
     } // end else if account cannot be created 
    } // end if method is post 
} // end register 
+0

에서 모든 파일을 제거하는 데 도움이 될 수 있습니다? 어쩌면 로그인했지만 작업에 액세스 할 수있는 권한이 없으며 오류 메시지가 실제 문제와 일치하지 않을 수 있습니까? – Nunser

+0

no .. 나는이 모든 시간 동안 정상적으로 로그인했으며 사용자의 대시 보드 인 계정 컨트롤러로 안내했다. 몇 시간 전까지 만해도 괜찮 았어. 나는이 문제를 일으킬 수있는 내가 바꾼 것을 생각할 수 없다. 심지어 나의 모든 변화를 되 돌렸다. 필자는 두 개의 개별 브라우저 (파이어 폭스와 크롬)에서 하나의 장치 (전화)로만 이것을 테스트했습니다. 문제가 내 전화와 관련이 있는지 궁금합니다. 전에는이 문제가 없었습니다. 사파리와 파이어 폭스 모두에서 근무할 때 데스크탑 컴퓨터에서 테스트 해 보겠습니다. 내 휴대 전화를 다시 시작했습니다 – bowlerae

+0

... 장치 또는 브라우저가 문제라고 생각하지 마십시오. – bowlerae

답변

0

글쎄, 나는 무엇을 INITIAL을 파악하지 문제는 아니지만 지금은 변경된 컨트롤러, 모델 및 뷰 파일을 모두 되돌려 놓으면 문제가 해결되는 것 같습니다. 그것은 초기 문제가 무엇인지 모르겠다는 것을 여전히 귀찮게합니다.

그러나 데이터베이스의 모든 암호를 해당 md5 해시로 업데이트 한 후에도 계속 문제가 발생한다는 것을 발견했습니다. 나는 Cake가 암호가 적절하게 일치하지 않도록 생각한 md5를 사용하지 않는다고 생각한다. 따라서 모든 변경된 파일을 되 돌린 후에도 암호는 모두 잘못되었습니다.

원래 문제가 무엇인지 파악하면 업데이트 할 예정입니다.

+0

무슨 뜻입니까 케이크가 md5를 사용하지 않습니까? – XuDing

0

당신이 (ACL 등의) 권한의 컨트롤러 설정이 있나요 그것은 tmp/cachetmp/models