I'm using Laravel with Angular 2 and I've run into an issue regarding the log in system that is built-in to Laravel. I can log in just fine, but if the user enters incorrect credentials it redirects back to the previous page, but this doesn't work the way I want it to. I want to define a custom path for the redirect. I already tried to use $loginPath and change that to a custom path, but that solution doens't work.
This is the default function from the vendor file "vendor\Illuminate\Foundation\Auth\AuthenticateUsers.php"
protected function sendFailedLoginResponse(Request $request)
{
return redirect()->back()
->withInput($request->only($this->username(), 'remember'))
->withErrors([
$this->username() => Lang::get('auth.failed'),
]);
}
And this is my login controller "\App\Http\Controllers\Auth\LoginController.php"
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
class LoginController extends Controller
{
use AuthenticatesUsers;
/**
* Where to redirect users after login / registration.
*
* @var string
*/
protected $redirectTo = '/api/loginCheck';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest', ['except' => 'logout']);
}
}
I want to be able to define my own path to where the user should be redirected upon giving incorrect log in credentials. If anyone could help me out, that'd be greatly appreciated.