phplaravellaravel-authentication

change user login method in Laravel


I'm editing a laravel project that use modules. I want change login field from email to mobile. In the user login controller in the login module, there are the following codes:

$loggedIn = $this->auth->login(
    [
        'email' => $request->email,
        'password' => $request->password,
    ],
    (bool) $request->get('remember_me', false)
);

I want user login with mobile, so I change the codes:

$loggedIn = $this->auth->login (
    [
        'mobile' => $request->email,
        'password' => $request->password,
    ],
    (bool) $request->get('remember_me', false)
);

But when I use this modified code, it does not change This means that users can still log in by entering an email! No mobile!


Solution

  • try this way...

    source link

      if (Auth::attempt(['email' => $email, 'password' => $password], $remember)) {
            // The user is being remembered...
        }