From 28238f6c1260e2bce622f543750ce7b53b42477a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Fri, 1 Oct 2021 16:49:37 +0200 Subject: [PATCH] Drop dummy "password" type (#896) --- bootstrap-types.php | 15 -------------- docs/fields.rst | 42 -------------------------------------- docs/model.rst | 2 +- tests-schema/ModelTest.php | 2 +- 4 files changed, 2 insertions(+), 59 deletions(-) diff --git a/bootstrap-types.php b/bootstrap-types.php index bcc854dce..ef363f8e7 100644 --- a/bootstrap-types.php +++ b/bootstrap-types.php @@ -12,7 +12,6 @@ final class Types { public const MONEY = 'money'; - public const PASSWORD = 'password'; } class MoneyType extends DbalTypes\Type @@ -28,18 +27,4 @@ public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $pla } } -class PasswordType extends DbalTypes\Type -{ - public function getName(): string - { - return Types::PASSWORD; - } - - public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform): string - { - return DbalTypes\Type::getType(DbalTypes\Types::STRING)->getSQLDeclaration($fieldDeclaration, $platform); - } -} - DbalTypes\Type::addType(Types::MONEY, MoneyType::class); -DbalTypes\Type::addType(Types::PASSWORD, PasswordType::class); diff --git a/docs/fields.rst b/docs/fields.rst index 0197369de..65e0e1995 100644 --- a/docs/fields.rst +++ b/docs/fields.rst @@ -259,45 +259,3 @@ views by default. .. php:method:: isHidden Returns true if UI should not render this field in views. - - -Password (after 1.5.0 release) -============================== - -.. php:namespace:: Atk4\Data\Field - -.. php:class:: Password - -`Field\\Password` is a class that implements proper handling of data passwords. -Without this class your password will be stored **unencrypted**. -Here is how to use it properly:: - - $user->addField('mypass', [\Atk4\Ui\FormField\Password::class]); - - $user->set('mypass', 'secret'); - $user->save(); - -Password is automatically hashed with `password_encrypt` before storing. If you -attempt to load existing record from database and `$user->get('mypass')` you -will always get `NULL`. - -There is another way to verify passwords using :php:meth:`Model::compare`:: - - $user = $user->loadBy('email', $email); - return $user->compare('password', $password); - -This should return `true` if your supplied password matches the one that is -stored. Final example:: - - // class User extends Model - - function changePass($old_pass, $new_pass) { - - if (!$this->compare('password', $old_pass)) { - throw new Exception('Old password is incorrect'); - } - - $this->set('password', $new_pass); - $this->save(); - } - diff --git a/docs/model.rst b/docs/model.rst index 8fb9e2714..f1432e0b6 100644 --- a/docs/model.rst +++ b/docs/model.rst @@ -345,7 +345,7 @@ a user invokable actions:: $this->addField('name'); $this->addField('email'); - $this->addField('password', ['type' => 'password']); + $this->addField('password'); $this->addUserAction('send_new_password'); diff --git a/tests-schema/ModelTest.php b/tests-schema/ModelTest.php index 2a8b21b2a..81029b533 100644 --- a/tests-schema/ModelTest.php +++ b/tests-schema/ModelTest.php @@ -175,7 +175,7 @@ protected function init(): void parent::init(); $this->addField('name'); - $this->addField('password', ['type' => 'password']); + $this->addField('password'); $this->addField('is_admin', ['type' => 'boolean']); $this->addField('notes', ['type' => 'text']);