Files
UNIT3D-Community-Edition/app/Http/Livewire/PasswordStrength.php
HDVinnie eddad86406 fix: phpstan errors
- this commit tackles more phpstan errors from the baseline.
- the 2024_06_19_210338_update_colum_types.php migration will have more added to it. This PR is draft until more baaseline errors are closed.
2024-06-19 21:19:02 -04:00

50 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
/**
* NOTICE OF LICENSE.
*
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D Community Edition
*
* @author HDVinnie <hdinnovations@protonmail.com>
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
*/
namespace App\Http\Livewire;
use Livewire\Component;
use ZxcvbnPhp\Zxcvbn;
class PasswordStrength extends Component
{
public string $password = '';
public string $passwordStrength = 'Weak';
public int $strengthScore = 0;
/**
* @var array<int, string>
*/
public array $strengthLevels = [
1 => 'Weak',
2 => 'Fair',
3 => 'Good',
4 => 'Strong',
];
final public function updatedPassword(string $password): void
{
$this->strengthScore = (new Zxcvbn())->passwordStrength($password)['score'];
}
final public function render(): \Illuminate\Contracts\View\View|\Illuminate\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\Foundation\Application
{
return view('livewire.password-strength');
}
}