CartLoginController.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace App\Http\Controllers\Auth;
  3. use App\Http\Controllers\Controller;
  4. use App\Shop\Admins\Requests\LoginRequest;
  5. use Illuminate\Foundation\Auth\AuthenticatesUsers;
  6. use Illuminate\Support\Facades\Auth;
  7. class CartLoginController 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. /**
  21. * Where to redirect users after login.
  22. *
  23. * @var string
  24. */
  25. protected $redirectTo = '/checkout';
  26. /**
  27. * Create a new controller instance.
  28. *
  29. */
  30. public function __construct()
  31. {
  32. $this->middleware('guest')->except('logout');
  33. }
  34. public function showLoginForm()
  35. {
  36. return view('front.carts.login');
  37. }
  38. /**
  39. * Login the customer
  40. *
  41. * @param LoginRequest $request
  42. * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\Response
  43. */
  44. public function login(LoginRequest $request)
  45. {
  46. $this->validateLogin($request);
  47. // If the class is using the ThrottlesLogins trait, we can automatically throttle
  48. // the login attempts for this application. We'll key this by the username and
  49. // the IP address of the client making these requests into this application.
  50. if ($this->hasTooManyLoginAttempts($request)) {
  51. $this->fireLockoutEvent($request);
  52. return $this->sendLockoutResponse($request);
  53. }
  54. $details = $request->only('email', 'password');
  55. $details['status'] = 1;
  56. if (auth()->attempt($details)) {
  57. return $this->sendLoginResponse($request);
  58. }
  59. // If the login attempt was unsuccessful we will increment the number of attempts
  60. // to login and redirect the user back to the login form. Of course, when this
  61. // user surpasses their maximum number of attempts they will get locked out.
  62. $this->incrementLoginAttempts($request);
  63. return $this->sendFailedLoginResponse($request);
  64. }
  65. }