Facing a Forbidden issue |
This is the code
view file:- login.php <form id="login" name="login" method="post" action=""> <input type="hidden" style="display:none;" value="<?php echo $this->security->get_csrf_hash();?>" name="csrf_test_name"> <div class=" row loginbox_content "> <div class="display-error text-center"></div> <br> <div class="input-group input-group-sm"> <span class="input-group-addon"> <span class="glyphicon glyphicon-envelope"></span> </span> <input id="email" name="email" class="form-control" type="text" placeholder="Email" maxlength="60"> </div> <br> <div class="input-group input-group-sm"> <span class="input-group-addon"> <span class="glyphicon glyphicon-lock"></span> </span> <input id="password" name="password" class="form-control" type="password" placeholder="Password" maxlength="20"> </div> <br> <div class="input-group input-group-sm"> <label> <input name="loginkeeping" id="loginkeeping1" value="loginkeeping" type="checkbox"> Remember Me </label> </div> </div> <div class="row "> <div class="col-lg-8 col-md-8 col-sm-8 col-xs-7 forgotpassword "> <a href="#" data-toggle="modal" data-target="#myModal">Forgot Password?</a> </div> <div class="col-lg-4 col-md-4 col-sm-4 col-xs-5 "> <button type ="submit" value="Submit" class="btn btn-default submit-btn">Submit <span class="glyphicon glyphicon-log-in"></span></button> </div> </div> </form> js file:: $.ajax({ method: "POST", url: base_url+'Admin/User/login_authenticate', data: {'email':email,'password':password,'remember':remember}, dataType: 'json', success: function(result) { if (result.error == 1) { $(".display-error").html(result.msg); $(".display-error").show(); $('.display-error').css('color','red'); $('.alert-success').attr('class','alert alert-danger'); } else { window.location.replace(base_url+"Admin/User/dashboard"); } }, error: function(err){ console.log(err) } }); controller:: public function login_authenticate() { $email = xss_clean($this->input->post('email')); $password = xss_clean($this->input->post('password')); $type = ($this->input->post('type') != '' ) ? $this->input->post('type') : ''; if($email == '' || $password == ''){ $this->error(); } else { $details = $this->Base_model->get_record_by_id('abc',array('email'=>$email,'present_role'=>1)); //set session if($details) { //if user is blocked if($details[0]['ustatus'] == '0'){ //json success message pass to custom.js $res = array('msg' => 'You have been blocked by admin. Please contact to admin.', 'error' => 1); print json_encode($res); } else{ $check_email_verify = $this->Base_model->check_existent('abc',array('email'=>$email,'email_verify'=>'1')); if($check_email_verify){ if($this->bcrypt->check_password($password, $details[0]['password'])){ $login_data = array( 'uid' => $details[0]['uid'], 'email' => $details[0]['email'], 'password' =>$details[0]['password'], 'logged_in' => TRUE ); $session_data = $this->session->set_userdata($login_data); $remember = $this->input->post('remember'); //set cookies if($remember == '1') { setcookie('email_cookie', $email, time()+3600*7, '/'); setcookie('password_cookie',$password, time()+3600*7,'/'); } if($type != ''){ //json success message pass to custom.js $res = array('msg' => 'redirect', 'error' => 0,); print json_encode($res); }else{ //json success message pass to custom.js $res = array('msg' => 'Logged in successfully.', 'error' => 0,); print json_encode($res); } } else{ //json success message pass to custom.js $res = array('msg' => 'Invalid user name and password.', 'error' => 1); print json_encode($res); } }else{ //json success message pass to custom.js $res = array('msg' => 'Please verify your email to login.Please check your email.', 'error' => 1,); print json_encode($res); } } } else{ //json success message pass to custom.js $res = array('msg' => 'Invalid user name and password.', 'error' => 1); print json_encode($res); } } } |
Messages In This Thread |
Facing a Forbidden issue - by jyoti sudyal - 02-22-2018, 12:09 AM
RE: Facing a Forbidden issue - by InsiteFX - 02-22-2018, 05:20 AM
RE: Facing a Forbidden issue - by jyoti sudyal - 02-22-2018, 05:50 AM
RE: Facing a Forbidden issue - by dave friend - 02-22-2018, 08:39 AM
RE: Facing a Forbidden issue - by jyoti sudyal - 02-22-2018, 10:29 PM
RE: Facing a Forbidden issue - by dave friend - 02-23-2018, 08:54 AM
RE: Facing a Forbidden issue - by jyoti sudyal - 02-25-2018, 10:14 PM
|