0
votes

I am integrating a controller which was working fine in laravel 5.4 for authentication a custom one which consist of throttles login trait as well.

  $validator = Validator::make($request->all(), [
        'username' => 'required',
        'password' => 'required',
    ]);
    if ($validator->fails()) {
        return redirect('/go/login')
                    ->withErrors($validator)
                    ->withInput();
    }
    return $this->hasTooManyLoginAttempts($request);
    if ($this->hasTooManyLoginAttempts($request)) {
        $this->fireLockoutEvent($request);
        return $this->sendLockoutResponse($request);
    }

    $credentials  =  $request->all();
    $email = $credentials['username'];
    $password = ($credentials['password']);
    if (Auth::attempt(['email' => $email, 'password' => $password])) {
        // session(['KCFINDER' => ['disabled' => false]]);
        $this->clearLoginAttempts($request);
        //return redirect('/go/verify/otp');
    }
    else{
        $request->session()->flash('login', 'Please Try Again. Username and Password didnot Match.');

        return redirect('/go/login');
    }

This doesnot work in laravel 5.7

$this->hasTooManyLoginAttempts($request) : this function returns

BadMethodCallException Method App\Http\Controllers\LoginController::username does not exist.

1
What do you mean it does not work? What error do you see? Can you be more specific?Yahya Uddin
$this->hasTooManyLoginAttempts($request); This function returns : BadMethodCallException Method App\Http\Controllers\LoginController::username does not exist.Rohan Kumar Shrestha
public function username() { return 'username'; } do you have this on your logincontroller ?Anar Bayramov

1 Answers

0
votes

you can create method username

public function username()
{
    return 'email';
}