Welcome Guest, Not a member yet? Register   Sign In
Error When Using Password Reset Function With Ion_auth | Have Username Identity
#1

[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
                
                
            );
#2

[eluser]atw[/eluser]
Hi phpmonster,

Surely if you are using username as the ion_auth identity you need to pass the username through to forgotten_password()?

Or am I missing something?
#3

[eluser]phpmonster[/eluser]
I tried that, it didn't work. It looks like the model is expecting an email.
#4

[eluser]atw[/eluser]
Well it seems logical that it would demand an email, since that is how the password change will be sent to the user...?

Why not just ask your users to give it their email address?




Theme © iAndrew 2016 - Forum software by © MyBB