ldc-gen-game-web/app/Http/Controllers/Bo/Auth/LoginController.php

70 lines
1.5 KiB
PHP
Raw Normal View History

<?php
2026-10-02 12:09:46 +02:00
declare(strict_types=1);
namespace App\Http\Controllers\Bo\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Contracts\Auth\StatefulGuard;
use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
2023-11-23 17:31:28 +01:00
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class LoginController extends Controller
{
use AuthenticatesUsers;
/**
* Create a new controller instance.
*/
public function __construct()
{
$this->middleware('guest:backend')->except('logout');
}
/**
* Get the guard to be used during authentication.
*/
protected function guard(): StatefulGuard
{
return Auth::guard('backend');
}
/**
* Show the application's login form.
*/
public function showLoginForm(): View
{
2026-10-02 12:09:46 +02:00
/** @var view-string $view */
$view = 'back::auth.login';
return view($view);
}
/**
* Where to redirect users after login.
*/
protected function redirectTo(): string
{
return response()->redirectToIntended()->getTargetUrl();
}
2023-11-23 17:31:28 +01:00
/**
* Attempt to log the user into the application.
*
2026-10-02 12:09:46 +02:00
* @return bool
2023-11-23 17:31:28 +01:00
*/
protected function attemptLogin(Request $request)
{
$credentials = $this->credentials($request);
// * Attempt login only using published users.
$credentials['published'] = true;
2026-10-02 12:09:46 +02:00
2023-11-23 17:31:28 +01:00
return $this->guard()->attempt(
$credentials,
$request->boolean('remember')
);
}
}