I am using Laravel 5.6, and tried to override the sendFailedLoginResponse method in LoginController, but i get the following error upon bad credentials:
Method App\Http\Controllers\Auth\LoginController::loginUsername does not exist.
I have two login forms on my website (on '/home' and '/login'). I want to redirect all failed attempts to '/login'. This is my code:
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
class LoginController extends Controller
{
use AuthenticatesUsers;
protected $redirectTo = '/home';
public function __construct()
{
$this->middleware('guest')->except('logout');
}
protected function sendFailedLoginResponse(Request $request)
{
return redirect('login')
->withInput($request->only($this->loginUsername(), 'remember'))
->withErrors([
$this->loginUsername() => $this->getFailedLoginMessage(),
]);
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire