jeudi 29 décembre 2016

Check max attempts : Laravel 5

I have a controller action method like below. Control comes in Controller code only if validations passes in Request class below.

public function Register(RegisterRequest $request) {

}

and Request class is like this

class RegisterRequest extends Request
{

    public function authorize()
    {
        return true;
    }

    public function rules()
    {
        return [
            'Password'      => 'required',
            'EmailAddress'  => 'required',
            'UserName'      => 'required',
        ];
    }
}

Now, I am trying to write below code in case the user exceeds defined max attempts.

if ($this->hasTooManyLoginAttempts($request)) {
    return  \Response::json([
        'Status'    =>  false,
        'Message'   =>  "Attempts locked",
        'Data'      =>  null,
    ], 403);
}

I think, I should write it in Request class? but if I do so, I will need to obtain the Request class instance for hasTooManyLoginAttempts method. So, not sure how should I proceed to implement this validation

Please suggest



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2iaXIP9
via IFTTT

Aucun commentaire:

Enregistrer un commentaire