php - Codeigniter: Integrating Ion Auth screens with Bootstrap Modals -
if user clicks on link on page, check if user logged in in controller method. if not logged show login screen modal onscreen.
works fine till point.
if user give wrong user name password. next page appears new page without css.
how return result modal login screen?
view/index.php
$('.index-product img').click(function() { var product = $('<div id="modal-productdetail" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="mymodallabel" aria-hidden="true"></div>'); $.ajax({ url: "<?php echo site_url('gallery/openproductdetail');?>", type: 'post', success: function(msg) { product.html(msg); product.modal('show'); } }); });
controller
function openproductdetail() { if (!$this->ion_auth->logged_in()) { redirect('auth/login'); } else { $this->load->view('modal/productdetail'); } }
view/login.php
<div class="modal-header"> <h4 id="mymodallabel">login account</h4> </div> <div id="loginmodal" class="modal-body"> <div class="row"> <?php echo form_open("auth/login");?> <div class="span3"> <ul class="unstyled" id="emaillogin"> <li><small class="muted">login email</small></li> <?php echo form_open("auth/login");?> <li> <input name="identity" value="" id="identity" type="text" placeholder="email address"/> <span class="help-block" id="emailerror" style="display:none;"></span> </li> <li> <input name="password" value="" id="password" type="password" placeholder="password"/> <span class="help-block" id="passworderror" style="display:none;"></span> </li> <li> <input style="display:none;" name="remember" value="1" id="remember" type="checkbox"> </li> <li> <a class="text-info" id="accountproblem" href="auth/forgot_password">account problem?</a> <input class="loginbutton" type="submit" name="submit" value="login"> <?php echo form_close();?> </li> <li> <div id="infomessage"><?php echo $message;?></div> </li> </ul> </div> </div> </div>
you need change login()
method in application/controllers/auth.php
. i'm think need add login()
method before redirect call this:
$location = ''; if($this->form_validation->run() == true) { //check see if user logging in //check "remember me" $remember = (bool) $this->input->post('remember'); if ($this->ion_auth->login($this->input->post('identity'), $this->input->post('password'), $remember)) { //if login successful //redirect them home page $this->session->set_flashdata('message', $this->ion_auth->messages()); $data = $this->ion_auth->messages(); $location = '/'; } else { $this->session->set_flashdata('message', $this->ion_auth->errors()); $data = $this->ion_auth->errors(); $location = 'auth/login'; } } else { $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', ); $data = $this->data; } if($this->input->is_ajax_request()) { echo json_encode(array('data' => $data)); } else { ($location) ? redirect($location, 'refresh') : $this->_render_page('auth/login', $data); }
and add js code handle response login()
method.
Comments
Post a Comment