How can I verify user passwords? new with current in base?

$passuser = Hash::make($request->password); $admin = User::where('email', $request->email) ->where('password', $passuser) ->first(); if ($admin && $admin == 1) return view('admin.home'); return view('admin.login')->withErrors('Неверный пароль'); 
  • and what does not work? - Captain Flint
  • added his code to the question - Aslero
  • added code is great. Well, what does not work? Mistake? Does not find? or, on the contrary, what should it not find? The question is what? - Captain Flint

1 answer 1

https://laravel.com/docs/5.7/hashing

The Hash::check(<обычная строка>, <хешированная строка>) method Hash::check(<обычная строка>, <хешированная строка>) allows you to check whether a given string of plain text matches the specified hash.

 if (Hash::check('plain-text', $hashedPassword)) { // Пароли соответствуют... } 

In your case you receive by mail

 $admin = User::where('email', $request->email)->first(); 

And check the password:

 if (!$admin) { // Не нашло по почте } if (Hash::check($request->password, $admin->password)) { // Пароли соответствуют... }