I am trying to use Ion Auth framework with my CodeIgniter application.
When user clicks a link request goes to Controller method and checks if user is logged in or not. If not then redirects to auth\login method. But I get html of the login page in my success(msg):alert(msg);
Ajax Request
$('img').click(function() {
$.ajax({
url: "<?php echo site_url('gallery/openProductDetail');?>",
type: 'POST',
success: function(msg) {
alert(msg);
}
});
});
Controller
function openProductDetail()
{
if (!$this->ion_auth->logged_in())
{
redirect('auth/login');
} else {
$this->load->view('modal/productdetail');
}
}
Login Page It is login.pho from original Ion Auth
<h1><?php echo lang('login_heading');?></h1>
<p><?php echo lang('login_subheading');?></p>
<div id="infoMessage"><?php echo $message;?></div>
<?php echo form_open("auth/login");?>
<p>
<?php echo lang('login_identity_label', 'identity');?>
<?php echo form_input($identity);?>
</p>
<p>
<?php echo lang('login_password_label', 'password');?>
<?php echo form_input($password);?>
</p>
<p>
<?php echo lang('login_remember_label', 'remember');?>
<?php echo form_checkbox('remember', '1', FALSE, 'id="remember"');?>
</p>
<p><?php echo form_submit('submit', lang('login_submit_btn'));?></p>
<?php echo form_close();?>
<p><a href="forgot_password"><?php echo lang('login_forgot_password');?></a></p>