Support the ongoing development of Laravel.io →
Authentication Views Validation
Last updated 2 years ago.
0

You will need to create your own login method. You can either store this in the LoginController that comes with Laravel or make your own.

Instead of using the attempt method you could easily determine which you need to validate (username / email) and change your query based on that. Here is a quick example I could think of based on using the Request variable, etc.

$user = \App\User::where('username', $request->input('username'))->first(); // grab the user
if($user) {
 // found user
 if(\Hash::check($request->input('password'), $user->password) {
   // user correct
   Auth::login($user);

    return redirect()->route('/');
  }
}

return redirect()->back()->withErrors(); // you would need to fill up the error
0

Sign in to participate in this thread!

Eventy

Your banner here too?

jahid56 jahid56 Joined 29 Oct 2016

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.