2014-04-05 3 views
0

내가 현재있는주소 원래 URL이 2 PARAMS

http://localhost/realestateagencyadministration/users/reset/859be257b603ce278c42dca470be642a/48/ 

그런 다음 사용자가 간다 이메일로 사용자는 아래의 링크를 보내는 리셋 암호를하고있는 중이 야했기 때문에, 발견 요청한 나는 그렇게

Error: The requested address '/realestateagencyadministration/users/reset/48' was not found on this server.

같은 오류를 제공 제출할 때 형태와 컨트롤러는 다음

public function reset($resetkey = null, $id = null) { 

     if (!$this->User->exists($id)) { 
      throw new NotFoundException(__('Invalid user')); 
     } 

     $result =$this->User->find('first', array('conditions' => array('User.id' => $id, 'User.resetKey' => "'" . $resetkey . "'"))); 

     if ($result) { 
      $message = __('<b>Please check your reset link</b>'); 
      $this->Session->setFlash($message); 
     } 

     if ($this->request->is('post')) { 
      if ($this->User->save()) { 
       $message = __('Your password has been reset'); 
       $this->Session->setFlash($message); 
      } else { 
       $message = __('Something has gone wrong. Please try later or <b>sign up again</b>'); 
       $this->Session->setFlash($message); 
      } 
     } 
     else { 
      $this->request->data = $this->User->findByIdAndResetkey($id, $resetkey); 
      $log = $this->User->getDataSource()->getLog(false, false); 
      debug($log); 
     } 
    } 

문제가 않습니다 0

어떻게 처리해야합니까?

+0

사용자가 'id'및 'resetKey'없이 페이지 만 재설정하면 어떻게됩니까? 아직도 못 찾니? – skywalker

+0

@skywalker 아무 매개 변수도 전달하지 않을 때 얻을 수 없습니다. 다시 설정할 수 없습니다. UsersController :: reset() – Enzero

+0

즉, reset이라는 이름의 두 가지 메소드가 있습니까? – skywalker

답변

0

답이 맞는지는 알 수 없으며 누구에게 수정해야하는지에 대한 제안이 있으면 의견을 말하십시오.

나는 skywalker의 제안을 받아 params를 바꿔 ID가 가장 먼저 나왔습니다.

public function reset($id = null,$resetkey = null) {

와 내가 깨끗하지 알고 코드를

if ($this->request->is(array('post', 'put'))) {      
     $data = $this->User->findById($id); 
     $data['User']['password'] = $this->request->data['User']['password']; 
     $data['User']['resetkey'] = ''; 
     if ($this->User->save($data)) { 
      $message = __('Your password has been changed, try logging in with your new password.'); 
      $this->Session->setFlash($message); 
     } else { 
      $message = __('Something has gone wrong. Please try again later.'); 
      $this->Session->setFlash($message); 
     } 
    } 

을 내 저장 변경 사람이 감사 감사하겠습니다 더 좋은 방법을 알고 있다면.

+0

비밀번호를 해싱하는 경우에는 작동하지 않습니다.해야 할 일로, 'beforeSave()'가 있습니까? – skywalker

+0

@skywalker 실제로 이것은 내가 구하기 전에 가지고있는 사실 때문에 효과가 있습니다. – Enzero

+0

괜찮습니다. – skywalker

0

이 시도 :

[1] 슬래시 (/)를 후행 제거

http://localhost/realestateagencyadministration 
    /users/reset/859be257b603ce278c42dca470be642a/48 

[2] 여전히 성공, 라우터 문 (응용 프로그램/구성/routes.php)을 추가하지 않는 경우 :

Router::connect('/users/reset/:resetkey/:id', 
    array('controller' => 'users', 'action' => 'reset'), 
    array('pass' => array('resetkey', 'id'))); // <-- must be in action argument order