sanchescom / lumen-login-throttling by sanchescom

Lumen login throttling.
1,031
1
1
Package Data
Maintainer Username: sanchescom
Maintainer Contact: sanches.com@mail.ru (Aleksandr Efimov)
Package Create Date: 2019-07-17
Package Last Update: 2019-08-26
Language: PHP
License: MIT
Last Refreshed: 2024-04-18 15:27:21
Package Statistics
Total Downloads: 1,031
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 1
Total Watchers: 1
Total Forks: 0
Total Open Issues: 0

Lumen Login Throttling

Laravel Login Throttling for Lumen framework

Installing

Require this package, with Composer, in the root directory of your project.

composer require sanchescom/lumen-login-throttling

Usage

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Sanchescom\Foundation\Auth\AuthenticatesUsers;
use Laravel\Lumen\Routing\Controller;

class AuthController extends Controller
{
    use AuthenticatesUsers;

    /** @var int */
    protected $maxAttempts = 3;

    /** @var int */
    protected $decayMinutes = 5;
    
    /**
     * Handle a login request to the application.
     *
     * @param  \Illuminate\Http\Request $request
     *
     * @throws \Illuminate\Validation\ValidationException
     *
     * @return mixed
     */
    public function login(Request $request)
    {
        $this->validateLogin($request);

        if ($this->hasTooManyLoginAttempts($request)) {
            $this->fireLockoutEvent($request);

            return $this->sendLockoutResponse($request);
        }

        if ($this->attemptLogin($request)) {
            return $this->sendLoginResponse($request);
        }
        
        $this->incrementLoginAttempts($request);

        return $this->sendFailedLoginResponse($request);
    }
}

Laravel Login Throttling documentation