Reputation: 5836
I have the following controller method:
function recover_password() {
$this->layout = 'frontend';
$this->loadModel('PasswordReset');
$this->Fonyker->recusive = -1;
if($this->data) {
$fields = array(
'Fonyker.fonykid',
'Fonyker.username',
'Fonyker.name',
'Fonyker.email'
);
$fonyker = $this->Fonyker->find('first', array(
'conditions' => array(
'OR' => array(
'Fonyker.email' => $this->data['Fonyker']['field'],
'Fonyker.username' => $this->data['Fonyker']['field']
)
),
'fields' => $fields
));
if($fonyker) {
$this->PasswordReset->create();
$passwordReset = array();
$passwordReset = array(
'PasswordReset' => array(
'code' => hash('sha256', $fonyker['Fonyker']['fonykid'].StringUtils::getRandomString(20)),
'fonykid' => $fonyker['Fonyker']['fonykid']
)
);
$this->PasswordReset->save($passwordReset);
$data = array(
'username' => $fonyker['Fonyker']['username'],
'code' => $passwordReset['PasswordReset']['code'],
'name' => $fonyker['Fonyker']['name'],
'email' => $fonyker['Fonyker']['email']
);
$this->_sendPasswordResetEmail($data);
} else {
}
}
}
This is the view:
<div class="prepend-top span-24">
<div class="prepend-8 span-8 append-8">
<?php
echo $this->Form->create('Fonyker', array('action' => 'recover_password'));
echo $this->Form->input('email', array(
'div' => array(
'class' => 'span-8'
),
'class' => 'input-text long',
'id' => 'FonykerEmail',
'label' => array(
'class' => 'inlined',
'text' => ''
),
'placeholder' => 'Username or Email'
));
echo $this->Form->submit('',array(
'div' => array(
'class' => 'span-2 last'
),
));
echo $this->Form->end();
?>
</div>
</div>
When I navigate to the page all I get is a blank page, and sometimes this error: Fatal error: Maximum execution time of 60 seconds exceeded in Unknown on line 0
UPDATE: The error seems to be loading my model, this is the model I have declared:
<?php
class PassswordReset extends AppModel {
var $name = 'PasswordReset';
var $displayField = 'id';
var $validate = array(
'code' => array(
'alphanumeric' => array(
'rule' => array('alphanumeric'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
'fonykid' => array(
'alphanumeric' => array(
'rule' => array('alphanumeric'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
)
);
}
?>
If I remove the loadModel()
call the page loads.
Upvotes: 0
Views: 422
Reputation: 11574
Do you have a table in the database called password_resets? Also, you may want to move your loadModel to the line right before you need it.
Upvotes: 1