0
votes

i have a problem with the auth component of cakephp i follow this guide to create the legacypasswordhasher https://book.cakephp.org/3.0/en/controllers/components/authentication.html i load the class in the appcontroller like this:

$this->loadComponent('Auth', [
        'authenticate' => [
            'Form' => [
                'passwordHasher' => [
                    'className' => 'Legacy',
                ]
            ]
        ]
    ]);

and i have created the legacypasswordhelper class in src/Auth like this:

namespace App\Auth;

use Cake\Auth\AbstractPasswordHasher;

class LegacyPasswordHasher extends AbstractPasswordHasher
{

public function hash($password)
{
    return sha1($password);
}

public function check($password, $hashedPassword)
{
    return sha1($password) === $hashedPassword;
}
}

?>

but if i login in my form the auth component dont run legacypassword functions. i use debugs in the hash and check function but it never shown. i hope anyone have a solution

1

1 Answers

0
votes

ok, i solve this problem. i didn't know that cake auth only works when you use the form function of cake. i have worked with a normal form

<form method="post" action="/users/login">

but you really have to

<?php echo $this->Form->create(); ?>

use it to make the legacy function work