Welcome Guest, Not a member yet? Register   Sign In
route with (:any) not working on Ion Auth
#1

I've got a problem to reset the password with Ion Auth.
Everything else in Ion Auth works fine.

The first lines of my config/routes.php are
PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');
$route['auth/reset_password'          'auth/reset_password';
$route['auth/reset_password/(:any)'   'auth/reset_password/$1';
$route['auth/forgot_password'         'auth/forgot_password';
$route['auth/login'                   'auth/login'

The first one (for testing) is working, but the second one with (:any) does not work. It redirects me always to auth/login
Do you know whats could be wrong?


PHP Code:
public function reset_password($code NULL)
    {
        if (!
$code)
        {
            
show_404();
        }
        
$user $this->ion_auth->forgotten_password_check($code);
        if (
$user)
        {
            
// if the code is valid then display the password reset form
            
$this->form_validation->set_rules('new'$this->lang->line('reset_password_validation_new_password_label'), 'required|min_length[' $this->config->item('min_password_length''ion_auth') . ']|max_length[' $this->config->item('max_password_length''ion_auth') . ']|matches[new_confirm]');
            
$this->form_validation->set_rules('new_confirm'$this->lang->line('reset_password_validation_new_password_confirm_label'), 'required');
            if (
$this->form_validation->run() == false)
            {
                
// display the form
                // set the flash data error message if there is one
                
$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
                
$this->data['min_password_length'] = $this->config->item('min_password_length''ion_auth');
                
$this->data['new_password'] = array(
                    
'name' => 'new',
                    
'id'   => 'new',
                    
'type' => 'password',
                    
'pattern' => '^.{'.$this->data['min_password_length'].'}.*$',
                );
                
$this->data['new_password_confirm'] = array(
                    
'name'    => 'new_confirm',
                    
'id'      => 'new_confirm',
                    
'type'    => 'password',
                    
'pattern' => '^.{'.$this->data['min_password_length'].'}.*$',
                );
                
$this->data['user_id'] = array(
                    
'name'  => 'user_id',
                    
'id'    => 'user_id',
                    
'type'  => 'hidden',
                    
'value' => $user->id,
                );
                
$this->data['csrf'] = $this->_get_csrf_nonce();
                
$this->data['code'] = $code;
                
// render
                
$this->_render_page('auth/reset_password'$this->data);
            }
            else
            {
                
// do we have a valid request?
                
if ($this->_valid_csrf_nonce() === FALSE || $user->id != $this->input->post('user_id'))
                {
                    
// something fishy might be up
                    
$this->ion_auth->clear_forgotten_password_code($code);
                    
show_error($this->lang->line('error_csrf'));
                }
                else
                {
                    
// finally change the password
                    
$identity $user->{$this->config->item('identity''ion_auth')};
                    
$change $this->ion_auth->reset_password($identity$this->input->post('new'));
                    if (
$change)
                    {
                        
// if the password was successfully changed
                        
$this->session->set_flashdata('message'$this->ion_auth->messages());
                    
 
                   echo "XXXXXX";//redirect("auth/login", 'refresh');
                    
}
                    else
                    {
                        
$this->session->set_flashdata('message'$this->ion_auth->errors());
                        
redirect('auth/reset_password/' $code'refresh');
                    }
                }
            }
        }
        else
        {
            
// if the code is invalid then send them back to the forgot password page
            
$this->session->set_flashdata('message'$this->ion_auth->errors());
            
redirect("auth/forgot_password"'refresh');
        }
    } 
Reply
#2

(This post was last modified: 08-29-2017, 02:25 PM by JediMind.)

Remove the '/$1'. auth/reset_password will automatically receive what is in (:any) as first param.


PHP Code:
$route['auth/reset_password/(:any)'   'auth/reset_password'
Reply
#3

Remove the other 3 routes. They are useless.
Reply
#4

If that won't work try this one:

PHP Code:
$route['auth/reset_password/(.+)'] = 'auth/reset_password/$1'
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB