1
public function login($local=false,$data=[])
{
$validator = Validator::make(($local)?$data:Request::all(), [
'username' => 'required',
'password' => 'required',
]);
if ($validator->fails()) {
return Response::json(array('status'=>'0','message'=>'Invalid parameters'));
}
if(Auth::attempt(($local)?$data:Request::all()))
{
//dd(Auth::user());
return Response::json(array('status'=>'1','message'=>'User logged in successfully'));
}
return Response::json(array('status'=>'1','message'=>'User log in failed'));
}
これは正常にログインしていますが、認証されたユーザーの詳細にアクセスしようとするとnullを返します。Laravel 5.2 Auth :: attempt()が成功してもAuth :: attempt()が機能しない場合
if(!Auth::check())
{
return Response::json(array('status'=>'0','message'=>'User not logged in'));
}
いずれかの提案があります。おかげ
どのAPIを使用していますか?同じサーバーまたは他の場所からの要求を意味しますか? – Qazi
@Qaziはい私はAPIコントローラを開発しようとしています、私は私のlocalhost上で実行しています。 –
セッションドライバとしては何を使用しますか? – naneri