[eluser]InterMedio[/eluser]
Hello.
I use code CodeIgniter_Ion_Auth and I need, if user logged in, then user redirect to viewsecretpage.php, if not - redirected to auth form.
And I created controller Secretpage:
Code:
<?php defined('BASEPATH') OR exit('No direct script access allowed');
if ( ! class_exists('Controller'))
{
class Secretpage extends CI_Controller {}
}
class Secretpage extends Controller {
function __construct()
{
parent::__construct();
$this->load->library('ion_auth');
$this->load->library('encrypt');
$this->load->library('session');
$this->load->library('form_validation');
$this->load->database();
$this->load->helper('url');
}
function index() {
if ( !$this->ion_auth->logged_in() )
{
redirect('auth/login', 'refresh');
}
else
{
$this->load->view('viewsecretpage');
}
}
}
and created view - viewsecretpage.php in folder views.
also I changed some code in method index() in file auth.php (Auth controller) to:
Code:
.....
function index()
{
if (!$this->ion_auth->logged_in())
{
//redirect them to the login page
redirect('auth/login', 'refresh');
}
elseif (!$this->ion_auth->is_admin())
{
/************************** Here I have made changes.*******/
//redirect them to the home page because they must be an administrator to view this
//redirect($this->config->item('base_url'), 'refresh');//previous
redirect('secretpage/index', 'refresh');//I changed
/*********************************************/
}
else
{ ............
And When I authorize, codeigniter print error: 404 Page Not Found.
Why? Also I tried inserted just $this->load->view('viewsecretpage'); but same situation.
Please help me. Thanks.