I am coded custom user system in Laravel 6.X. In my Login Controller i have this validation code:
$email = $request->email;
$validator = Validator::make($request->all(), [
'email' => 'bail|email|required|max:32|exists:users,email',
'password' => ['required','min:1','max:32',
function ($attribute, $value, $fail) {
$users = DB::table('users')->where('email', $email)->get(); // Get user info (Exception is in here)
if (hash('sha256', $value) !== $users[0]->Password) { // Check if hashed password equals
$fail($attribute.' is wrong.'); // If not equal then return error message
}
},
],
]);
I am store my passwords with SHA256 Hashing. If password not equals to database password then return an error message to user. But i am getting an exception "Undefined variable: email".