Replies: 2 comments
-
i somehow handled this in a dirty way. but with fortify you can easily overwrite the attempt with authenticateUsing method and prevent the extra queries. |
Beta Was this translation helpful? Give feedback.
-
Add to user model static method findByEmail. This method will search user by email using blindIndex public static function findByEmail(string $email)
{
return User::whereBlind('email', 'email_index', $email)
->first();
} In Auth attempt you can use Closure Auth::attempt(
[
function(Builder $query){
$user = User::findByEmail($this->email);
if (!$user) throw ValidationException::withMessages(['email' => 'Invalid email or password']);
$query->where('id', $user->id);
return $query;
},
'password' => $this->password, //auto hashed password in User model,
], $this->remember)) { |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
recently i encrypted my email column in the database and this breaks the authentication process.
here in the attemptLogin method
return $this->guard()->attempt( $this->credentials($request), $request->filled('remember') );
what i did is to remove the logics and do the job manually. but im not sure if it is a best way to do that.
$operator = Operator::query()->whereBlind('email','operator_email_index',$request['email'])->first(); if($operator && Hash::check($request['password'],$operator->password)){ return true; } return false;
could you please help me with this scenario?
Beta Was this translation helpful? Give feedback.
All reactions