Welcome Guest, Not a member yet? Register   Sign In
Users cannot get past login page. Website returns an invalid email/password message.
#1

[eluser]charleslittle.tx[/eluser]
I have a codeigniter website on a ubuntu 12.04 server. I am fairly new to this coding business so I am not sure what's wrong. On my website, I have corrected for mod_rewrite with a root folder .htaccess file and the homepage links are now working.

The problem is that users are unable to authenticate when they enter the correct credentials. I have searched for hours on this and have not found a solution. Users are able to sign up and change their password, but they cannot login. Please help. I belive my code is written correctly so I am not sure where the error is.


Please help!
#2

[eluser]InsiteFX[/eluser]
Well if you do not show your code no one will be able to help you.
#3

[eluser]charleslittle.tx[/eluser]
The website lives at: http://184.72.244.138.

I am not certain what code is necessary to share:

This is the login section of my auth file:

class Auth extends Controller {

function __construct()
{
parent::__construct();
$this->load->library('form_validation');
$this->load->model('account_settings_model');
$this->load->database();}

//redirect if needed, otherwise display the user list

function index()
{
if ( $this->ion_auth->logged_in() )
{
$data = array(
'tpl' => 'content_right/main',
'title' => 'The Web Site'
);
$this->load->view('main_layout', $data);}
else
{$data = array(
'tpl' => 'auth/login',
'title' => 'Login'
);
$this->load->view('main_layout_login', $data);} }
function frame()
{if ( $this->ion_auth->logged_in() )
{
$data = array(
'tpl' => 'content_right/frame',
'title' => 'The Web Site'
);
$this->load->view('main_layout', $data);}
else
{
$data = array(
'tpl' => 'auth/login',
'title' => 'Login'
);
$this->load->view('main_layout_login', $data); } }

/*function index()
{
if (!$this->ion_auth->logged_in())
{
//redirect them to the login page
redirect('auth/login', 'refresh');}
elseif (!$this->ion_auth->is_admin())
{
//redirect them to the home page because they must be an administrator to view this
redirect($this->config->item('base_url'), 'refresh');}
else
{//set the flash data error message if there is one
$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');

//list the users
$this->data['users'] = $this->ion_auth->get_users_array();
$this->load->view('auth/index', $this->data);}}*/

//log the user in
function login()
{if (!empty($_POST))
{
$remember = (bool) $this->input->post('remember');

if ($this->ion_auth->login($this->input->post('email'), $this->input->post('password'), $remember))
{
//if the login is successful redirect them back to the dashboard page

$data = array(
'login_succesful' => 'login');

$user_info = $this->base->get_row('users', $this->session->userdata('id'));

echo json_encode($data);}
else
{
//if the login was un-successful redirect them back to the login page
$data = array(
'login_succesful' => 'no');

echo json_encode($data);}}
else
{$data = array(
'tpl' => 'auth/login',
'title' => 'Login');

$this->load->view('main_layout_login', $data);}


/*//validate form input
$this->form_validation->set_rules('email', 'Email Address', 'required|valid_email');
$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('email'), $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($this->config->item('base_url'), '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['email'] = array('name' => 'email',
'id' => 'email',
'type' => 'text',
'value' => $this->form_validation->set_value('email'),);
$this->data['password'] = array('name' => 'password',
'id' => 'password',
'type' => 'password',);


$this->data = array(
'tpl' => 'auth/login',
'title' => 'Login' );

$this->load->view('main_layout', $this->data);

// $this->load->view('auth/login', $this->data);}*/}

I also have an ion_auth model. I don't have a problem with rewrite right now so I don't think there is an issue with the .htaccess file. I hope that this helps! Thank you for the reply.
#4

[eluser]charleslittle.tx[/eluser]
login.php view - login process:

// Login Form Validator. Login Process.
$("#login_form").validate({

submitHandler: function(form) {

var email = $('#email').val();
var password = $('#password').val();

$.ajax({
type: 'POST',
url: SITE_ROOT+'auth/login',
data: ({email:email, password: password}),
dataType: 'text json',
success: function(data){

if(data.login_succesful == 'no')
{alert('Invalid email or password');}
else
{[removed] = SITE_ROOT+'auth';}}});},
rules: {
email: {required: true,
email: true},
password: {required: true,
minlength: 6}}});


// click login when push enter
$(" #password, #email ").keypress( function(e)
{
var email = $( "#email" ), password = $( "#password" );
if( parseInt ( e.which ) == 13)
{$.ajax({
type: 'POST',
url: SITE_ROOT+'auth/login',
data: ({email:email.val(), password: password.val()}),
dataType: 'text json',
success: function(data){

if(data.login_succesful == 'no')
{
alert('Invalid email or password');
$( this ).dialog( "close" );
}
else
{
[removed] = SITE_ROOT+'auth';
$( this ).dialog( "close" );}}});}});
#5

[eluser]charleslittle.tx[/eluser]
.htaccess file:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteRule ^$ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico)

RewriteRule ^(.*)$ index.php/$1 [L]

The links are working so I don't think it is a rewrite issue.
#6

[eluser]InsiteFX[/eluser]
This should be:
Code:
class Auth extends Controller {

// should be I think ION Auth uses a MY_Controller in application/core
class Auth extends MY_Controller {
#7

[eluser]charleslittle.tx[/eluser]
Would it be more helpful if I put the code into a bitbucket account? I know it might be hard to read through here (I had to make some adjustments to the parens so that it wasn't as long). Do you know what the problem might be? I will make your change.
#8

[eluser]charleslittle.tx[/eluser]
I made the MY_Controller change and got a HTTP 500 error.
#9

[eluser]charleslittle.tx[/eluser]
Let me lastly mention that I had the site running properly on another server. I moved the site to this server and now I am having this issue.
#10

[eluser]Matias Perrone[/eluser]
People,

I had the same problem, I think the issue is due the "valid_email" function does not allows dots before the @ so, it is defined as follows:

Code:
function valid_email($address)
{
return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $address)) ? FALSE : TRUE;
}

But it should be like this:

Code:
function valid_email($address)
{
return ( ! preg_match("/^([a-z0-9\+_\-\.]+)(\.[a-z0-9\+_\-\.]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $address)) ? FALSE : TRUE;
}

This solves the issue, but in order to do not have problems with future updates create you own helper "MY_email_helper.php" or the prefix you have set instead of "MY_" in the config file.




Theme © iAndrew 2016 - Forum software by © MyBB