align backend auth patterns
This commit is contained in:
parent
b3266b38c8
commit
299efe0839
23 changed files with 249 additions and 142 deletions
|
|
@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue