I have the credentials username, phonunmber, password and device serial number saved in my phpmyadmin database. I want to input the username, phonunmber and password and if all of them matches with device serial number in the databse, then the user can log in. How can i do that?
P.S device serial number is saved only in the database. I dont want to input as the other credentials. Just i want to check if the username, phonunumber, password and device serial number matches all together.
Advertisement
Answer
Have a look at “Manually authenticating users” section in https://laravel.com/docs/8.x/authentication#authenticating-users
Normally only email and password are used to authenticate user in Laravel
$credentials = $request->only('email', 'password'); if (Auth::attempt($credentials)) { $request->session()->regenerate(); return redirect()->intended('dashboard'); }
But you can use any fields that you want to authenticate by passing them to Auth::attempt
$result = Auth::attempt([ 'username' => $request->username, 'password' => $request->password, 'phonunumber' => $request->phonunumber, 'device_serial_number' => $request->device_serial_number ]); if($result) { ... }