LoginController.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace App\Http\Controllers\Auth;
  3. use App\Http\Controllers\Controller;
  4. use App\Providers\RouteServiceProvider;
  5. use Illuminate\Foundation\Auth\AuthenticatesUsers;
  6. use Illuminate\Http\Request;
  7. class LoginController extends Controller
  8. {
  9. /*
  10. |--------------------------------------------------------------------------
  11. | Login Controller
  12. |--------------------------------------------------------------------------
  13. |
  14. | This controller handles authenticating users for the application and
  15. | redirecting them to your home screen. The controller uses a trait
  16. | to conveniently provide its functionality to your applications.
  17. |
  18. */
  19. use AuthenticatesUsers;
  20. public const PANEL = '/panel';
  21. /**
  22. * Where to redirect users after login.
  23. *
  24. * @var string
  25. */
  26. protected $redirectTo = self::PANEL;
  27. /**
  28. * Create a new controller instance.
  29. *
  30. * @return void
  31. */
  32. public function __construct()
  33. {
  34. $this->middleware('guest')->except('logout');
  35. }
  36. /**
  37. * Get the login username to be used by the controller.
  38. *
  39. * @return string
  40. */
  41. public function username()
  42. {
  43. return 'username';
  44. }
  45. /**
  46. * Validate the user login request.
  47. *
  48. * @param Request $request
  49. * @return void
  50. *
  51. */
  52. protected function validateLogin(Request $request)
  53. {
  54. $request->validate([
  55. $this->username() => ['required', 'string'],
  56. 'password' => ['required', 'string'],
  57. 'g-recaptcha-response' => ['required', 'cutlet_recaptcha']
  58. ]);
  59. }
  60. }