Laravel Limit Login Attempts

David Carr

Laravel Framework Tutorials PHP & MySQL

When using Laravel's Login system for authentication it has a default of 5 failed login attempts and a lockout time for 1 minute. I previously documented how to override this in Laravel earlier versions of Laravel add login throttling with custom login controller This however no longer works on Laravel 5.6 instead you can set public properties to set the maxAttempts and decayMinutes.

Put these in your LoginController:

/**
 * Set how many failed logins are allowed before being locked out.
 */
public $maxAttempts = 1;

/**
 * Set how many seconds a lockout will last.
 */
public $decayMinutes = 30;

The above would set the login attempts to be set at 1 and a lockout for 30 minutes.

Laravel Modules Your Logo Your Logo Your Logo

Become a sponsor

Help support the blog so that I can continue creating new content!

Sponsor

My Latest Book

Modular Laravel Book - Laravel: The Modular way

Learn how to build modular applications with Laravel Find out more

Subscribe to my newsletter

Subscribe and get my books and product announcements.

Fathom Analytics $10 discount on your first invoice using this link

© 2006 - 2024 DC Blog. All code MIT license. All rights reserved.