[eluser]phpmonster[/eluser]
Am using the username as the identity instead of 'email'.
when I run the password reset function inputting an email. it throws an error:
Message: Trying to get property of non-object
Filename: libraries/Ion_auth.php
Line Number: 195
CONTROLLER
Code:
//forgot password
function forgot_password()
{
$this->form_validation->set_rules('email', 'Email Address', 'required');
if ($this->form_validation->run() == false)
{
//setup the input
$this->data['email'] = array('name' => 'email',
'id' => 'email',
);
//set any errors and display the form
$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
$this->load->view('auth/forgot_password', $this->data);
}
else
{
//run the forgotten password method to email an activation code to the user
$forgotten = $this->ion_auth->forgotten_password($this->input->post('email'));
if ($forgotten)
{ //if there were no errors
$this->session->set_flashdata('message', $this->ion_auth->messages());
redirect("auth/login", 'refresh'); //we should display a confirmation page here instead of the login page
}
else
{
$this->session->set_flashdata('message', $this->ion_auth->errors());
redirect("auth/forgot_password", 'refresh');
}
}
}
LIB
Code:
public function forgotten_password($identity) //changed $email to $identity
{
if ( $this->ci->ion_auth_model->forgotten_password($identity) ) //changed
{
// Get user information
$user = $this->get_user_by_identity($identity); //changed to get_user_by_identity from email
$data = array(
'identity' => $user->{$this->ci->config->item('identity', 'ion_auth')},
'forgotten_password_code' => $user->forgotten_password_code
);