<?php

namespace App\Domains\Auth\Services;

use App\Domains\Auth\Models\User;
use App\Domains\Authorization\Enums\RoleCode;
use Illuminate\Support\Facades\Hash;

class AdminCredentialVerifier
{
    public function verify(string $email, string $password): bool
    {
        $admin = User::query()
            ->where('email', mb_strtolower(trim($email)))
            ->where('rol_codigo', RoleCode::Admin->value)
            ->first();

        return $admin !== null
            && ! $admin->locked_until?->isFuture()
            && Hash::check($password, $admin->getAuthPassword());
    }
}
