I'm trying to authenticate my and user via ajax using axios
in my laravel and vuejs app. the authentication is working well and returning the auth user like this:
public function loginUser(Request $request){
$credentials = $request->only('email', 'password');
if (Auth::attempt($credentials)) {
// Authentication passed...
$user = Auth::user();
Auth::loginUsingId($user->id, TRUE);
if (Auth::check()) {
// The user is logged in successfully...
return response()->json(Auth::id());
}else{
return response()->json("cannot chech user loggin user");
}
}else{
return response()->json("failled authentication");
}
}
This code is returning me the log's user id very well. the problem is when I triying to retrieve the Auth user in other function, like this:
public function testAuth(Request $request){
// return response()->json(Auth::user());
if (Auth::check()) {
// The user is logged in...
return response()->json(Auth::user());
}else{
return response()->json("the user is not login");
}
}
The result that Im getting is "the user is not login" thank for help.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire