2

USing some code from the tutorial for making blogs, I managed to add users... problem is the moment i try to log in and THE INFAMOUS 512 error pops up. any ideas if this is coming from my core.php file or has to do with my code?

here it is in case you're wondering

view:

<div class="users form">
    <?php echo $this->Form->create('User'); ?>
    <fieldset>
        <legend><?php echo __('Add User'); ?></legend>
        <?php
            echo $this->Form->input('username');
            echo $this->Form->input('password');
            echo $this->Form->input('account_type', array(
            'options' => array('admin', 'user'),
            'empty' => '(choose one)'
        ?>
    </fieldset>
    <?php echo $this->Form->end(__('Submit')); ?>
</div>
<div class="actions">
    <h3><?php echo __('Actions'); ?></h3>
    <ul>

        <li><?php echo $this->Html->link(__('List Users'), array('action' => 'index')); ?></li>
    </ul>
</div>

model before save function which hashes said passwords:

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;
}



}

and the controller functions involved with the login and logout function

public function beforeFilter() {
parent::beforeFilter();
// Allow users to register and logout.
$this->Auth->allow('add', 'logout');
}

public function login() {
    if ($this->request->is('post')) {
        if ($this->Auth->login()) {
            return $this->redirect($this->Auth->redirect());
        }
        $this->Session->setFlash(__('Invalid username or password, try again'));
    }
}

public function logout() {
    return $this->redirect($this->Auth->logout());
}
    }
Sean Perez
  • 99
  • 1
  • 12
  • possible duplicate http://stackoverflow.com/questions/21113819/cakephp-how-do-i-implement-blowfish-hashing-for-passwords – Sougata Bose Oct 28 '14 at 10:08
  • tried using the code there.. it's still giving me the 512 error. i duno if it has to do with the core php cipher salt – Sean Perez Oct 28 '14 at 11:27
  • have changed the cipher at the time of installing? – Sougata Bose Oct 28 '14 at 11:31
  • as it turned out my issue wasn't with my code or even my salt.... it had to do with my database cutting the hashed passwords short due to setting it to a very short limit..... go figure – Sean Perez Oct 28 '14 at 13:55

0 Answers0