align backend auth patterns

This commit is contained in:
Yisroel Baum 2026-08-02 20:57:25 +03:00
parent b3266b38c8
commit 299efe0839
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
23 changed files with 249 additions and 142 deletions

View file

@ -3,7 +3,6 @@
namespace App\User;
use App\Shared\ValueObject\EmailAddress;
use Illuminate\Support\Facades\Hash;
class EloquentUserRepository implements UserRepository
{
@ -11,7 +10,7 @@ class EloquentUserRepository implements UserRepository
{
$model = UserModel::create([
'email' => $dto->email->value(),
'password' => Hash::make($dto->password),
'passwordHash' => $dto->passwordHash,
]);
return $this->toDomain($model);
@ -27,18 +26,12 @@ class EloquentUserRepository implements UserRepository
return $this->toDomain($model);
}
public function findByCredentials(
EmailAddress $email,
string $password,
): ?User
public function findByEmail(EmailAddress $email): ?User
{
$model = UserModel::query()
->where('email', $email->value())
->first();
if (
$model === null
|| ! Hash::check($password, $model->password)
) {
if ($model === null) {
return null;
}
@ -50,6 +43,7 @@ class EloquentUserRepository implements UserRepository
return new User(
id: $model->id,
email: new EmailAddress($model->email),
passwordHash: $model->passwordHash,
);
}
}