Laravel을 4.0에서 4.1로 업그레이드 한 후 내 사용자 인증이 깨졌습니다.Laravel 4 : 사용자가 로그인하지 않았습니다. 로그인했습니다.
본인이 문서에서 제공하는 업그레이드 가이드를 따랐습니다.
이제 로그인하면 한 요청에 대해서만 지속되는 것처럼 보입니다.
예를 들어, 내 HomeController의 색인 방법, 난과 같이 로그인을 강제로 :
Auth::login(User::find(1), true);
$user = Auth::user();
return View::make('layout', array('user' => $user));
나는 레이아웃에 $ 사용자를 에코와 완벽하게 사용자 정보를 표시합니다.
그러나 로그인하기 위해 Auth를 사용하는 첫 번째 줄을 제거한 다음 컨트롤러를 수정하면 페이지가 비워집니다.
EDIT
I 여기서 사용자 인증 털어 3.1.0을 사용하고이 do_login() 함수이다. 나는 Confide :: logAttempt가 true를 반환하는지 확인하기 위해 첫 번째 'if'의 바로 앞에 덤프 문자 &을 덤프했습니다.
나는 또한 전체 블록을 숨기고 간단히 'echo Auth :: user()'를 완료했으며 실제로 로그인 한 사용자의 User 모델을 반환합니다. 여기
public function do_login()
{
$input = array(
'email' => Input::get('email'), // May be the username too
'username' => Input::get('email'), // so we have to pass both
'password' => Input::get('password'),
'remember' => Input::get('remember'),
);
// If you wish to only allow login from confirmed users, call logAttempt
// with the second parameter as true.
// logAttempt will check if the 'email' perhaps is the username.
// Get the value from the config file instead of changing the controller
if (Confide::logAttempt($input, Config::get('confide::signup_confirm')))
{
// Redirect the user to the URL they were trying to access before
// caught by the authentication filter IE Redirect::guest('user/login').
// Otherwise fallback to '/'
// Fix pull #145
return Redirect::intended('/'); // change it to '/admin', '/dashboard' or something
}
else
{
$user = new User;
// Check if there was too many login attempts
if(Confide::isThrottled($input))
{
$err_msg = Lang::get('confide::confide.alerts.too_many_attempts');
}
elseif($user->checkUserExists($input) and ! $user->isConfirmed($input))
{
$err_msg = Lang::get('confide::confide.alerts.not_confirmed');
}
else
{
$err_msg = Lang::get('confide::confide.alerts.wrong_credentials');
}
return Redirect::action('[email protected]')
->withInput(Input::except('password'))
->with('error', $err_msg);
}
}
내가했던 모든 클린 Laravel의 설치 만드는 것이 었습니다 다음 내 컨트롤러/모델/뷰를 복사 한 말을 매우 죄송 해요 logAttempt() 함수
public function logAttempt($credentials, $confirmed_only = false, $identity_columns = array())
{
// If identity columns is not provided, use all columns of credentials
// except password and remember.
if(empty($identity_columns))
{
$identity_columns = array_diff(
array_keys($credentials),
array('password','remember')
);
}
// Check for throttle limit then log-in
if(! $this->reachedThrottleLimit($credentials))
{
$user = $this->repo->getUserByIdentity($credentials, $identity_columns);
if(
$user &&
($user->confirmed || ! $confirmed_only) &&
$this->app['hash']->check(
$credentials['password'],
$user->password
)
)
{
$remember = isset($credentials['remember']) ? $credentials['remember'] : false;
$this->app['auth']->login($user, $remember);
return true;
}
}
$this->throttleCount($credentials);
return false;
}
사용자가 로그인 한 곳에서 로그인 코드를 공유하십시오. – Anam
동일한 문제가있어서 Barryvdh 디버그 표시 줄에 문제가 있음이 밝혀졌습니다.이 디버그 표시 줄을 사용하는 경우 최신 dev-master로 업그레이드하십시오 그리고 그것은 문제를 해결해야합니다 – glendaviesnz
고마워 glendaviesnz,하지만 그 디버그 막대를 사용하고 있지 않습니다. 내 코드베이스에 대한 전 세계적 검색을 통해 절대적으로 확실합니다. – brianrhea