Hey,
I installed CakePHP 5:
composer create-project --prefer-dist cakephp/app:~5.0 app
I installed Authentication:
composer require "cakephp/authentication:^3.0"
In app_local.php config the MySQL database connect successfully.
Added this:
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
user_login VARCHAR(255) NOT NULL,
user_pass VARCHAR(255) NOT NULL,
created DATETIME,
modified DATETIME
);
I use user_login (not email) and user_pass (not password) fields.
Run: bin/cake bake all users
I changed the files email->user_login and password->user_pass.
I read and do: CMS Tutorial - Authentication - 5.x
I read more articles and forums from internet, but the auth works with CakePHP 2, 3, 4, but does not works with 5.
Please help me how to.
My file:
<?php
class PhpassPasswordHasher extends AbstractPasswordHasher {
public function hash($password) {
return 'xyz';
}
public function check($password, $hashedPassword) {
return true;
}
}
Please help me.
1. How to set password?
src/Model/Entity/User.php
use Authentication\PasswordHasher\DefaultPasswordHasher; // how to use my file instead this?
class User extends Entity
{
protected function _setUserPass(string $password) : ?string
{
if (strlen($password) > 0) {
return (new DefaultPasswordHasher())->hash($password); // how to use my pw hasher?
}
return null;
}
}
2. How to use my class for login?
3. Where do I save my file?
4. In my file, what need use/namespace etc?
Thanks.
In CakePHP 2 (PHP 5 and 7) I can create own PhpassPasswordHasher. This PHP 8.3 and CakePHP 5 it’s complicated for me.