94 lines
2.4 KiB
PHP
94 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Fo\Auth;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Providers\RouteServiceProvider;
|
|
use Illuminate\Contracts\Auth\StatefulGuard;
|
|
use Illuminate\Contracts\View\View;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
|
use Illuminate\Foundation\Auth\ThrottlesLogins;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\Session;
|
|
|
|
class LoginController extends Controller
|
|
{
|
|
use AuthenticatesUsers;
|
|
use ThrottlesLogins;
|
|
|
|
/**
|
|
* Where to redirect users after login.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $redirectTo = RouteServiceProvider::HOME;
|
|
|
|
/**
|
|
* Create a new controller instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
$this->middleware('guest:frontend')->except('logout');
|
|
}
|
|
|
|
/**
|
|
* Get the guard to be used during authentication.
|
|
*
|
|
* @return \Illuminate\Contracts\Auth\StatefulGuard
|
|
*/
|
|
protected function guard(): StatefulGuard
|
|
{
|
|
return Auth::guard('frontend');
|
|
}
|
|
|
|
/**
|
|
* Show the application's login form.
|
|
*
|
|
* @return \Illuminate\View\View
|
|
*/
|
|
public function showLoginForm(): View
|
|
{
|
|
return view('theme::auth.login');
|
|
}
|
|
|
|
/**
|
|
* The user has been authenticated.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param \Illuminate\Database\Eloquent\Model $user
|
|
* @return void
|
|
* @phpcs:disable Squiz.Commenting.FunctionComment.TypeHintMissing, Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
|
*/
|
|
protected function authenticated(Request $request, Model $user): void
|
|
{
|
|
$user->last_connection = \now();
|
|
$user->saveOrFail();
|
|
Session::flash('info', trans('Vous êtes à présent connecté'));
|
|
}
|
|
|
|
/**
|
|
* The user has logged out of the application.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return void
|
|
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
|
*/
|
|
protected function loggedOut(Request $request): void
|
|
{
|
|
Session::flash('info', trans('Vous êtes à présent déconnecté'));
|
|
}
|
|
|
|
/**
|
|
* Get the post register / login redirect path.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function redirectPath(): string
|
|
{
|
|
return response()->redirectToIntended()->getTargetUrl();
|
|
}
|
|
}
|