BlowfishPasswordHasher ไม่อนุญาตให้เข้าสู่ระบบ

ใน cakephp ได้เปลี่ยนจาก simplePasswordHasher เป็น BlowfishPasswordHasher ฉันเพิ่มโค้ดต่อไปนี้และใส่ความคิดเห็นในการอ้างอิงทั้งหมดไปยังวิธี simplehasher แบบเก่า แต่ฉันไม่สามารถเข้าสู่ระบบได้ ฉันสามารถสร้างผู้ใช้ใหม่ด้วย BlowfishPasswordHasher ได้ แต่ตอนนี้การเข้าสู่ระบบใช้งานไม่ได้ใช่ไหม

ลิงก์ด้านล่างไม่สามารถแก้ไขปัญหาได้เนื่องจากฉันไม่สามารถเข้าสู่ระบบได้ แต่ฉันเห็นผู้ใช้ใหม่ที่มีรหัสผ่านที่ถูกต้อง

CakePHP - ฉันจะใช้การแฮชปักเป้าสำหรับรหัสผ่านได้อย่างไร

http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html

//userscontroller
public function login() {
    if ($this->request->is('post')) {
        if ($this->Auth->login()) {
           return $this->redirect($this->Auth->redirectUrl()); //for 2.3 and above versions, docs are old

        }
        $this->Session->setFlash(__('Invalid username or password, try again'));
    }
}  

//user
App::uses('BlowfishPasswordHasher', 'Controller/Component/Auth');

public function beforeSave($options = array()) {
    if (isset($this->data[$this->alias]['password'])) {
        $passwordHasher = new BlowfishPasswordHasher();
        $this->data[$this->alias]['password'] = $passwordHasher->hash(
            $this->data[$this->alias]['password']
        );
    }
    return true;
}

//new user
  <?php echo $this->Form->create('User'); ?>
    <h2><?php echo __('Add User2'); ?></h2>
    <?php
    echo $this->Form->input('username');
    echo $this->Form->input('password');

// ใน appcontroller public $components = array( "อีเมล", 'เซสชัน', 'Auth');

ฟังก์ชั่นสาธารณะ beforeFilter () {

        $this->Auth->authError = 'You cant access this page';
        $this->Auth->loginRedirect= array('controller' => 'users', 'action' => 'dashboard');
        $this->Auth->logoutRedirect= array('controller' => 'users','action' => 'login'  );
        $this->Auth->authorize= array('Controller');
        $this->Auth->unauthorizedRedirect=  '/users/dashboard'; 
        $this->set("logged_in", $this->Auth->loggedIn())

//user model
    public $validate = array(
        'username' => array(
            'required' => array(
                'rule' => array('notEmpty'),
                'message' => 'A username is required'
            )
        ),
        'password' => array(
            'required' => array(
                'rule' => array('notEmpty'),
                'message' => 'A password is required'
            )
        )

person ajt    schedule 14.08.2014    source แหล่งที่มา
comment
ช่องรหัสผ่านของคุณมีความยาวเท่าไร? แฮชปักเป้ามีความยาวมากกว่า sha1   -  person ADmad    schedule 14.08.2014
comment
varchar (255) ถูกต้องหรือไม่   -  person ajt    schedule 14.08.2014
comment
ใช่ มันนานพอแล้ว แต่ถ้าคุณเปลี่ยนมันเมื่อเร็วๆ นี้ อย่าลืมล้างแคชของโมเดลด้วย   -  person ADmad    schedule 14.08.2014
comment
ฉันไม่ได้เปลี่ยนช่องรหัสผ่านใน mysql แล้วมันมีปัญหาอะไร?   -  person ajt    schedule 14.08.2014
comment
คุณยังไม่ได้รวมการกำหนดค่าการตรวจสอบสิทธิ์ของคุณในโพสต์ มีการกำหนดค่าอย่างเหมาะสมให้ใช้ BlowfishPasswordHasher หรือไม่   -  person ADmad    schedule 14.08.2014
comment
การกำหนดค่าองค์ประกอบ Auth ของคุณมีลักษณะอย่างไร (@ADmad ทุบตีฉันเลย) และคุณแน่ใจหรือว่าคุณกำลังพยายามเข้าสู่ระบบด้วยผู้ใช้ที่สร้างขึ้นใหม่ เช่น ผู้ใช้ที่มีแฮชปักเป้าอยู่ในฐานข้อมูลจริงๆ และก่อนที่การคาดเดาอย่างบ้าคลั่งจะเริ่มต้นขึ้น คุณได้ลองทำอะไรไปแล้วเพื่อแก้ไขปัญหานี้   -  person ndm    schedule 14.08.2014
comment
ฉันได้แก้ไขคำถามและเพิ่มการกำหนดค่าการตรวจสอบสิทธิ์แล้ว มีอะไรอีกแจ้งให้เราทราบและฉันไม่ได้รับข้อผิดพลาดใด ๆ นอกเหนือจากผู้ใช้ที่ไม่ถูกต้องกับผู้ใช้ที่สร้างขึ้นใหม่ด้วย blowfishpasswordhasher ฉันจะกำหนดค่า BlowfishPasswordHasher อย่างถูกต้องได้อย่างไร เนื่องจากนี่อาจเป็นปัญหาที่ฉันไม่ได้พบในเอกสาร   -  person ajt    schedule 14.08.2014
comment
โอเค ขอบคุณ นี่ในตัวกรองก่อนหน้าจะเป็นอะไร? 'รับรองความถูกต้อง' =› array ( 'แบบฟอร์ม' =› array ( 'passwordHasher' =› 'ปักเป้า' )   -  person ajt    schedule 14.08.2014


คำตอบ (1)


คุณยังไม่ได้กำหนดค่าการตรวจสอบสิทธิ์ให้ใช้ BlowfishPasswordHasher ดังนั้นระบบจึงยังคงใช้แฮชเริ่มต้นอยู่ ระบุคีย์ passwordHasher ดังที่แสดงใน เช่น ที่นี่.

person ADmad    schedule 14.08.2014