Laravel-Backpack /
CRUD
We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace Backpack\CRUD\app\Http\Controllers\Auth; |
||||
| 4 | |||||
| 5 | use Backpack\CRUD\app\Library\Auth\AuthenticatesUsers; |
||||
| 6 | use Illuminate\Http\Request; |
||||
| 7 | use Illuminate\Routing\Controller; |
||||
| 8 | |||||
| 9 | class LoginController extends Controller |
||||
| 10 | { |
||||
| 11 | protected ?string $loginPath = null; |
||||
| 12 | protected ?string $redirectTo = null; |
||||
| 13 | protected ?string $redirectAfterLogout = null; |
||||
| 14 | |||||
| 15 | protected $data = []; // the information we send to the view |
||||
| 16 | |||||
| 17 | /* |
||||
| 18 | |-------------------------------------------------------------------------- |
||||
| 19 | | Login Controller |
||||
| 20 | |-------------------------------------------------------------------------- |
||||
| 21 | | |
||||
| 22 | | This controller handles authenticating users for the application and |
||||
| 23 | | redirecting them to your home screen. The controller uses a trait |
||||
| 24 | | to conveniently provide its functionality to your applications. |
||||
| 25 | | |
||||
| 26 | */ |
||||
| 27 | use AuthenticatesUsers { |
||||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||||
| 28 | logout as defaultLogout; |
||||
| 29 | } |
||||
| 30 | |||||
| 31 | /** |
||||
| 32 | * Create a new controller instance. |
||||
| 33 | * |
||||
| 34 | * @return void |
||||
| 35 | */ |
||||
| 36 | public function __construct() |
||||
| 37 | { |
||||
| 38 | $guard = backpack_guard_name(); |
||||
| 39 | |||||
| 40 | $this->middleware("guest:$guard", ['except' => 'logout']); |
||||
| 41 | |||||
| 42 | // ---------------------------------- |
||||
| 43 | // Use the admin prefix in all routes |
||||
| 44 | // ---------------------------------- |
||||
| 45 | |||||
| 46 | // If not logged in redirect here. |
||||
| 47 | $this->loginPath ??= backpack_url('login'); |
||||
| 48 | |||||
| 49 | // Redirect here after successful login. |
||||
| 50 | $this->redirectTo ??= backpack_url('dashboard'); |
||||
| 51 | |||||
| 52 | // Redirect here after logout. |
||||
| 53 | $this->redirectAfterLogout ??= backpack_url('login'); |
||||
| 54 | } |
||||
| 55 | |||||
| 56 | /** |
||||
| 57 | * Return custom username for authentication. |
||||
| 58 | * |
||||
| 59 | * @return string |
||||
| 60 | */ |
||||
| 61 | public function username() |
||||
| 62 | { |
||||
| 63 | return backpack_authentication_column(); |
||||
| 64 | } |
||||
| 65 | |||||
| 66 | /** |
||||
| 67 | * The user has logged out of the application. |
||||
| 68 | * |
||||
| 69 | * @param \Illuminate\Http\Request $request |
||||
| 70 | * @return mixed |
||||
| 71 | */ |
||||
| 72 | protected function loggedOut(Request $request) |
||||
|
0 ignored issues
–
show
The parameter
$request is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||
| 73 | { |
||||
| 74 | return redirect($this->redirectAfterLogout); |
||||
| 75 | } |
||||
| 76 | |||||
| 77 | /** |
||||
| 78 | * Get the guard to be used during logout. |
||||
| 79 | * |
||||
| 80 | * @return \Illuminate\Contracts\Auth\StatefulGuard |
||||
| 81 | */ |
||||
| 82 | protected function guard() |
||||
| 83 | { |
||||
| 84 | return backpack_auth(); |
||||
| 85 | } |
||||
| 86 | } |
||||
| 87 |