I am trying to authenticate my request in a Laravel API (5.4). Even following the authentication documentation documentation, whenever I submit the request, I have the following return:
Not valid token provider.
LoginController:
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Contracts\Session\Session;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
use App\User;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
class LoginController extends Controller
{
use AuthenticatesUsers;
protected $redirectTo = '/home';
public function __construct()
{
$this->middleware('guest');
}
public function login(Request $request)
{
$data = $request->all();
$success = true;
$user = User::where('email', $data['email'])->first();
if ($user == null) {
return $this->outputJSON(null, "Endereço de e-mail incorreto!", 404);
} elseif (Hash::check($data['password'], $user->getAuthPassword())) {
$user->remember_token = str_random(60);
$user->save();
$result = array(
'message' => 'Login realizado com sucesso! ',
'data' => $user,
'success' => true,
);
return response()->json($result);
} else {
return $this->outputJSON(null, "Senha inválida", 404);
}
}
public function getLogout()
{
Session::flush();
return redirect('/');
}
}