Cleanup, refactoring.
This commit is contained in:
parent
fc73956165
commit
42f9a0ea11
|
|
@ -1,6 +1,6 @@
|
||||||
# The MIT License (MIT)
|
# The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2017 Marcus Olsson <contact@marcusolsson.me>
|
Copyright (c) 2018 Marcus Olsson <contact@marcusolsson.me>
|
||||||
|
|
||||||
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
> of this software and associated documentation files (the "Software"), to deal
|
> of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
|
||||||
16
README.md
16
README.md
|
|
@ -4,6 +4,9 @@
|
||||||
[![Total downloads][ico-downloads]][link-packagist]
|
[![Total downloads][ico-downloads]][link-packagist]
|
||||||
[![Software License][ico-license]](LICENSE.md)
|
[![Software License][ico-license]](LICENSE.md)
|
||||||
[![Build Status][ico-travis]][link-travis]
|
[![Build Status][ico-travis]][link-travis]
|
||||||
|
[![Scrutinizer Score][ico-scrutinizer]][link-scrutinizer]
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
A simple implementation of zxcvbn for Laravel 5. This package allows you to access "zxcvbn-related" data on a passphrase in the application and also to use zxcvbn as a standard validator.
|
A simple implementation of zxcvbn for Laravel 5. This package allows you to access "zxcvbn-related" data on a passphrase in the application and also to use zxcvbn as a standard validator.
|
||||||
|
|
||||||
|
|
@ -149,13 +152,22 @@ $ phpunit
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
|
The MIT License (MIT). Please see the [License File](LICENSE.md) for more information.
|
||||||
|
|
||||||
© 2017 [Marcus Olsson](https://marcusolsson.me).
|
© 2018 [Marcus Olsson](https://marcusolsson.me).
|
||||||
|
|
||||||
[ico-version]: https://img.shields.io/packagist/v/olssonm/l5-zxcvbn.svg?style=flat-square
|
[ico-version]: https://img.shields.io/packagist/v/olssonm/l5-zxcvbn.svg?style=flat-square
|
||||||
|
|
||||||
[ico-downloads]: https://img.shields.io/packagist/dt/olssonm/l5-zxcvbn.svg?style=flat-square
|
[ico-downloads]: https://img.shields.io/packagist/dt/olssonm/l5-zxcvbn.svg?style=flat-square
|
||||||
|
|
||||||
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
|
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
|
||||||
|
|
||||||
[ico-travis]: https://img.shields.io/travis/olssonm/l5-zxcvbn/master.svg?style=flat-square
|
[ico-travis]: https://img.shields.io/travis/olssonm/l5-zxcvbn/master.svg?style=flat-square
|
||||||
|
|
||||||
|
[ico-scrutinizer]: https://img.shields.io/scrutinizer/g/olssonm/l5-zxcvbn.svg?style=flat-square
|
||||||
|
|
||||||
[link-packagist]: https://packagist.org/packages/olssonm/l5-zxcvbn
|
[link-packagist]: https://packagist.org/packages/olssonm/l5-zxcvbn
|
||||||
|
|
||||||
[link-travis]: https://travis-ci.org/olssonm/l5-zxcvbn
|
[link-travis]: https://travis-ci.org/olssonm/l5-zxcvbn
|
||||||
|
|
||||||
|
[link-scrutinizer]: https://scrutinizer-ci.com/g/olssonm/l5-zxcvbn
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ class ZxcvbnServiceProvider extends ServiceProvider
|
||||||
/**
|
/**
|
||||||
* Extend the Laravel Validator with the "zxcvbn_min" rule
|
* Extend the Laravel Validator with the "zxcvbn_min" rule
|
||||||
*/
|
*/
|
||||||
Validator::extend('zxcvbn_min', function($attribute, $value, $parameters, $validator) {
|
Validator::extend('zxcvbn_min', function($attribute, $value, $parameters) {
|
||||||
$zxcvbn = new ZxcvbnPhp();
|
$zxcvbn = new ZxcvbnPhp();
|
||||||
$zxcvbn = $zxcvbn->passwordStrength($value);
|
$zxcvbn = $zxcvbn->passwordStrength($value);
|
||||||
$target = 5;
|
$target = 5;
|
||||||
|
|
@ -30,7 +30,7 @@ class ZxcvbnServiceProvider extends ServiceProvider
|
||||||
return ($zxcvbn['score'] >= $target);
|
return ($zxcvbn['score'] >= $target);
|
||||||
}, 'Your :attribute is not secure enough.');
|
}, 'Your :attribute is not secure enough.');
|
||||||
|
|
||||||
Validator::replacer('zxcvbn_min', function($message, $attribute, $rule, $parameters) {
|
Validator::replacer('zxcvbn_min', function($message, $attribute) {
|
||||||
$message = str_replace(':attribute', $attribute, $message);
|
$message = str_replace(':attribute', $attribute, $message);
|
||||||
return $message;
|
return $message;
|
||||||
});
|
});
|
||||||
|
|
@ -38,7 +38,7 @@ class ZxcvbnServiceProvider extends ServiceProvider
|
||||||
/**
|
/**
|
||||||
* Extend the Laravel Validator with the "zxcvbn_min" rule
|
* Extend the Laravel Validator with the "zxcvbn_min" rule
|
||||||
*/
|
*/
|
||||||
Validator::extend('zxcvbn_dictionary', function($attribute, $value, $parameters, $validator) {
|
Validator::extend('zxcvbn_dictionary', function($attribute, $value, $parameters) {
|
||||||
$email = null;
|
$email = null;
|
||||||
$username = null;
|
$username = null;
|
||||||
|
|
||||||
|
|
@ -61,7 +61,7 @@ class ZxcvbnServiceProvider extends ServiceProvider
|
||||||
|
|
||||||
}, 'Your :attribute is insecure. It either matches a commonly used password, or you have used a similar username/password combination.');
|
}, 'Your :attribute is insecure. It either matches a commonly used password, or you have used a similar username/password combination.');
|
||||||
|
|
||||||
Validator::replacer('zxcvbn_dictionary', function($message, $attribute, $rule, $parameters) {
|
Validator::replacer('zxcvbn_dictionary', function($message, $attribute) {
|
||||||
$message = str_replace(':attribute', $attribute, $message);
|
$message = str_replace(':attribute', $attribute, $message);
|
||||||
return $message;
|
return $message;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue