Ion Auth не перенаправляется должным образом во время входа в систему

Я использую ion auth для создания системы входа в систему для моего приложения codeigniter. Я создал маршруты для лучших URL-адресов, например;

http://localhost/myApplication/index.php/auth/login

сейчас

http://localhost/myApplication/index.php/login

«Правило маршрутизации», которое я использую для достижения этой цели,

$route['login'] = 'auth/login';

и он работает нормально, т.е. ввод его прямо в адресную строку браузера приводит меня на страницу входа в систему. Проблема возникает при входе в систему. Когда я нажимаю кнопку входа, я возвращаюсь к

http://localhost/myApplication/index.php/auth/login

где, конечно, я получаю ошибку «404 страница не найдена». Я не могу понять, какая часть ion auth вызывает такое поведение. Я проверил метод login() контроллера auth.php, и ничего там (насколько я вижу) не является виновником.

Мой файл route.php выглядит так:

$route['default_controller'] = "pages/view";
$route['404_override'] = '';

$route['login'] = 'auth/login';
$route['register'] = 'auth/create_user';

$route['(:any)'] = 'pages/view/$1';

и метод login();

//log the user in
function login()
{
    $this->data['title'] = "Login";

    //validate form input
    $this->form_validation->set_rules('identity', 'Identity', 'required');
    $this->form_validation->set_rules('password', 'Password', 'required');

    if ($this->form_validation->run() == true)
    {
        //check to see if the user is logging in
        //check for "remember me"
        $remember = (bool) $this->input->post('remember');

        if ($this->ion_auth->login($this->input->post('identity'), $this->input->post('password'), $remember))
        {
            //if the login is successful
            //redirect them back to the home page
            $this->session->set_flashdata('message', $this->ion_auth->messages());
            redirect('/', 'refresh');
        }
        else
        {
            //if the login was un-successful
            //redirect them back to the login page
            $this->session->set_flashdata('message', $this->ion_auth->errors());
            redirect('auth/login', 'refresh'); //use redirects instead of loading views for compatibility with MY_Controller libraries
        }
    }
    else
    {
        //the user is not logging in so display the login page
        //set the flash data error message if there is one
        $this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');

        $this->data['identity'] = array('name' => 'identity',
            'id' => 'identity',
            'type' => 'text',
            'value' => $this->form_validation->set_value('identity'),
        );
        $this->data['password'] = array('name' => 'password',
            'id' => 'password',
            'type' => 'password',
        );

        $this->_render_page('login', $this->data);
    }
}

Я ценю любые взгляды, которые могут помочь пролить свет на эту тайну. Спасибо.


person user1678293    schedule 31.12.2013    source источник


Ответы (1)


Вам нужно открыть views/auth/login.php и изменить

<?php echo form_open("auth/login");?>

To:

<?php echo form_open("login");?>
person joni jones    schedule 31.12.2013
comment
Кажется, ответ был тут же спрятан у всех на виду, спасибо, @joni. - person user1678293; 01.01.2014