2014-07-07 1 views
0

Laravel 인증이 완벽하게 작동합니다. 비밀번호 변경 기능이 포함되었습니다. 암호를 변경 한 후 첫 번째 사용자 (uid = "1")를 제외한 모든 사용자에 대해 로그인이 정상적으로 작동합니다. 이 사용자에게는 기본 암호 해시 만 작동합니다. 다른 암호 해시의 경우 로그인 시도가 실패합니다. 내 코드는 아래에 주어진다 :암호 변경 후 Laravel Auth :: attempt()가 실패 함

사용자 컨트롤러 로그인 완료

public function postSignin() { 
    if (Auth::attempt(array('email'=>Input::get('email'), 'password'=>Input::get('password')))) { 
     return Redirect::to('users/dashboard')->with(array('message' => 'You are now logged in!', 'email' => Input::get('email'))); 
    } else { 
     return Redirect::to('users/login') 
     ->with('message', 'Your username/password combination was incorrect') 
     ->withInput(); 
    } 

    } 

테이블 스키마

Schema::create('users', function($table) 
     { 
      $table->increments('id'); 
      $table->string('firstname', 20); 
      $table->string('lastname', 20); 
      $table->string('email', 100)->unique(); 
      $table->string('password', 255); 
      $table->string('remember_token', 255); 
      $table->timestamps(); 
     }); 

비밀번호 변경 컨트롤러 기능

public function postUpass() { 
    $user = User::find(Input::get('uid')); 
    if((Input::get('password'))==(Input::get('passconf'))){ 
     $user->password = Hash::make(trim(Input::get('password'))); 
     $user->save(); 
     echo "Done"; 
     //echo Hash::make(trim(Input::get('password'))); 
    } 
    else { 
     echo "Check Passwords Again"; 
    } 

누군가 제발 도와주세요.

답변

0

아직 댓글을 달 수 없기 때문에 답변을 게시하여 의견을 구해야합니다. postUpass 함수에서 사용자에게 액세스하는 방식을 변경하여 최종 사용자가 쉽게 변경하여 다른 사용자의 비밀번호를 업데이트 할 수 있도록 제안하고 싶습니다.

//change this 
$user = User::find(Input::get('uid')); 
//to this 
$user = Auth::user(); 
//since the user needs to be logged in 
//to change their password anyway 

또한 postUpass 함수에 게시하면 항상 '암호 다시 확인'알림이 반환됩니다.