jeudi 13 août 2015

Laravel 5 two-way table login

I am trying to configure a laravel 5 app that will login users based on their username with password, if the username and password method fails the app will try to check the other table if the data in the username variable is available in my case their employee_id. So here is my code for logging users in with the conventional laravel method:

 $authdetails = array(
            'email' => $request->input('email'),
            'password' => $request->input('password')
         );
         if (Auth::attempt($authdetails)) {
             // Authentication passed...
             return redirect()->to('/home');
         }
        else {
              return back()->with('error', 'Invalid username or password')->withInput();
          }
     }

How do I login users with a different table if the first method fails?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire