Support the ongoing development of Laravel.io →
Authentication
Last updated 1 year ago.
0

Auth::attempt takes any array of required values, so just pass your condition in there like this:

Auth::attempt([
    'login'     => $login,
    'password'  => $password,
    'confirmed' => 1
]);
Last updated 8 years ago.
0

I'm looking into the AuthenticatesAndRegisterUsers.php file, where the attempt function is called inside postLogin() function. I already modified it to ask for username in place of email as credential, but how do I add the "confirmed" field and how do I specify that I want it equal to 1? The code is

$this->validate($request, [
    'username' => 'required', 'password' => 'required',
]);

$credentials = $request->only('username', 'password');

if ($this->auth->attempt($credentials, $request->has('remember')))
{
    return redirect()->intended($this->redirectPath());
}
0

Ok, I've changed the $credentials variable to

$credentials = [
        'username' => $request['username'],
        'password' => $request['password'],
        'confirmed' => 1
    ];  

and now it works.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Kumidan kumidan Joined 29 Apr 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.