Added length test to PasswordField
This commit is contained in:
parent
f3b4b4e454
commit
2a342ad9f9
1 changed files with 11 additions and 1 deletions
|
|
@ -11,13 +11,14 @@
|
||||||
namespace PhangoApp\PhaModels\CoreFields;
|
namespace PhangoApp\PhaModels\CoreFields;
|
||||||
use PhangoApp\PhaModels\Forms\PasswordForm;
|
use PhangoApp\PhaModels\Forms\PasswordForm;
|
||||||
use PhangoApp\PhaUtils\Utils;
|
use PhangoApp\PhaUtils\Utils;
|
||||||
|
use PhangoApp\PhaI18n\I18n;
|
||||||
|
|
||||||
class PasswordField extends CharField {
|
class PasswordField extends CharField {
|
||||||
|
|
||||||
|
|
||||||
function __construct($size=255)
|
function __construct($size=255)
|
||||||
{
|
{
|
||||||
|
$this->min_length=5;
|
||||||
$this->size=$size;
|
$this->size=$size;
|
||||||
$this->form='PhangoApp\PhaModels\CoreForms::PasswordForm';
|
$this->form='PhangoApp\PhaModels\CoreForms::PasswordForm';
|
||||||
|
|
||||||
|
|
@ -41,6 +42,15 @@ class PasswordField extends CharField {
|
||||||
$hash_password=$token_pass.'_'.sha1($token_pass.'_'.$value);
|
$hash_password=$token_pass.'_'.sha1($token_pass.'_'.$value);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if(strlen($value)<$this->min_length)
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->std_error=I18n::lang('common', 'password_min_length', 'Minimal password length:').' '.$this->min_length;
|
||||||
|
|
||||||
|
return '';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$hash_password=password_hash($value, PASSWORD_DEFAULT);
|
$hash_password=password_hash($value, PASSWORD_DEFAULT);
|
||||||
|
|
||||||
return $hash_password;
|
return $hash_password;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue