<?php

namespace App\Validation;

use App\Libraries\HashLibrary;
use App\Libraries\UserAuth;

class PasswordValidation
{
    public static function is_password_strong($password): bool
    {
        $password = trim($password);
        // Validate password strength
        $uppercase = preg_match('@[A-Z]@', $password);
        $lowercase = preg_match('@[a-z]@', $password);
        $number = preg_match('@[0-9]@', $password);
        $specialChars = preg_match('@[^\w]@', $password);

        if (!$uppercase || !$lowercase || !$number || !$specialChars || strlen($password) < 8) {
            return false;
        } else {
            return true;
        }
    }
    public static function correct_current_password($password): bool
    {
        $model = model('UserModel');
        $user = $model->getUser(UserAuth::id());
        $password = trim($password);

        return HashLibrary::verify($password, $user->password);
    }
}
