Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
marco76tv committed Sep 24, 2024
1 parent 81f4e7b commit 8ff91f1
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions Filament/Forms/Components/PasswordStrengthField.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

namespace Modules\UI\Filament\Forms\Components;

// use bjeavons\ZxcvbnPhp\Zxcvbn;
use Filament\Forms\Components\TextInput;

class PasswordStrengthField extends TextInput
{
protected string $view = 'ui::ui::filament.forms.components.password-strength';

public function evaluateStrength(): static
{
$this->afterStateUpdated(function (string $state) {
// $zxcvbn = new Zxcvbn();
// $result = $zxcvbn->passwordStrength($state);

// Ottieni il punteggio della password (da 0 a 4)
// $score = $result['score'];
/*
// Puoi gestire la logica in base al punteggio qui (opzionale)
if ($score < 3) {
$this->warning('La tua password è troppo debole!');
} else {
$this->info('La tua password è abbastanza forte.');
}
*/

// $this->state(['passwordStrengthScore' => $score]);
});

return $this;
}
}

0 comments on commit 8ff91f1

Please sign in to comment.