You can use the make:auth command. It doesn't change any values in your database table or your migrations.
But, you have multiple errors in the code you've posted so i don't know whether you've manually written it or copied it.
Here's your method:
public function authenticate(Request $request) {
$username = request()->username;
$password = request()->password;
$credentials = array('profile_mobile_username' => $username , 'password' => $password);
$attempt = Auth::attempt($credentials);
$hashed_password = profile::where('profile_mobile_username', $username)->first()- >profile_mobile_password_hashed;
$check = Hash::check($password, $hashed);
if (Auth::attempt($credentials)) {
return view('index');
}
return dd($attempt);
}
- Why are you attempting to authenticate the user twice?
- Where are you assigning the
$hashedvariable? I only see$hashed_password. - Are you certain that the password value in the database is hashed? If it's a plain value, it's going to fail as the attempt method automatically hashes it behind the scenes to match the hashed value in the database.
- Try using
use Authinstead ofuse Illuminate\Support\facades\Auth;
Providing you actually have a hashed value in the database, it should be as simple as:
if (Auth::attempt(['profile_mobile_username' => request('username'), 'password' => request('password')]) {
// success
}