Rebuilding my system using laravel 5.4. I do an ajax login that works, but i want to add the remember option to the auth. the documentation says this about setting remember:
if (Auth::attempt(['email' => $email, 'password' => $password], $remember)) {
// The user is being remembered...
}
But since my logincontroller does not have any visible login function, i am struggling with how to override it with my current logincontroller. in my route i am just calling LoginController@login. and i have no override on the login function being called..
This is my logincontroller:
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Lang;
class LoginController extends Controller
{
use AuthenticatesUsers;
protected $redirectTo = '/minside';
public function __construct()
{
$this->middleware('guest', ['except' => 'logout']);
}
protected function sendLoginResponse(Request $request)
{
$request->session()->regenerate();
$this->clearLoginAttempts($request);
if ($request->ajax()) {
error_log($this->guard()->user(),'0');
return response()->json($this->guard()->user(), 200);
}
return $this->authenticated($request, $this->guard()->user())
?: redirect()->intended($this->redirectPath());
}
protected function sendFailedLoginResponse(Request $request)
{
if ($request->ajax()) {
return response()->json([
'error' => Lang::get('auth.failed')
], 401);
}
return redirect()->back()
->withInput($request->only($this->username(), 'remember'))
->withErrors([
$this->username() => Lang::get('auth.failed'),
]);
}
}
via Havihavi