EllisLab text mark
Advanced Search
73 of 89
73
   
Ion Auth - Lightweight Auth System based on Redux Auth 2
Posted: 07 September 2011 05:35 PM   [ # 1081 ]   [ Rating: 0 ]
Joined: 2011-09-07
2 posts

Hurr durr ignore me it was one of those stupid mistakes you make every now and again XD

 
Posted: 08 September 2011 12:53 PM   [ # 1082 ]   [ Rating: 0 ]
Avatar
Joined: 2010-03-31
70 posts

Is Ion-Auth free for comercial useage ?

 
Posted: 09 September 2011 03:57 AM   [ # 1083 ]   [ Rating: 0 ]
Joined: 2011-05-30
31 posts

How to update firstname and other field?

 
Posted: 09 September 2011 12:57 PM   [ # 1084 ]   [ Rating: 0 ]
Avatar
Joined: 2009-01-09
73 posts

Any ideas why notification emails stopped coming through as HTML after upgrade?

 
Posted: 09 September 2011 01:19 PM   [ # 1085 ]   [ Rating: 0 ]
Joined: 2011-09-07
7 posts

Hi Ben, everybody,

Good morning / good evening (whatever is applicable) to all of you. I have been developing a web application locally using CI and Ion Auth - I’m still a newbie to both though. Anyway, I encountered the following problems upon deploying the application to the web hosting service I subscribed to, they were not observed in the development environment (my computer running wampserver). At first I had an issue with the database but its solved already smile Now, I noticed a problem during page load / login screen (when running on the web server), the application keeps on “redirecting” to auth/login and does it forever or until I hit the stop button, its like this:

http://mysite.com/auth/auth/auth/auth/auth/auth/auth/auth/auth/auth/auth/login.html 

So I tweaked the auth/index function from:

if (!$this->ion_auth->logged_in())
    
{
        
//redirect them to the login page
        
redirect('auth/login''refresh');
    

to

if (!$this->ion_auth->logged_in())
    
{
        
//redirect them to the login page
        
$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->load->view('login'$this->data);
    

It seem to have solved the issue so I thought everything was ok already until I tried to login. It doesn’t matter if I logged in correctly or not, the page will just always return to the login screen - plus no flashdata are shown when they normally should be flashed. I checked the database, sessions are created but the user_data remains blank. Could you please advice me on what I might have missed? Thank you so much in advance!

 
Posted: 09 September 2011 01:33 PM   [ # 1086 ]   [ Rating: 0 ]
Avatar
Joined: 2009-01-09
73 posts

Hey there KristiMonterror. What does your auth/login look like? I’m guessing you have a redirect there as well that is causing the endless loop.

 
Posted: 09 September 2011 01:39 PM   [ # 1087 ]   [ Rating: 0 ]
Joined: 2011-09-07
7 posts
spmckee - 09 September 2011 05:33 PM

Hey there KristiMonterror. What does your auth/login look like? I’m guessing you have a redirect there as well that is causing the endless loop.

Hello spmckee. auth/login looks like the following:

function login()
    
{
        $this
->data['title'"Login";
        
        if (
$this->ion_auth->logged_in())
        
{
            
//already logged in so no need to access this page
            
redirect($this->config->item('base_url'), 'refresh');
        
}

        
//validate form input
        
$this->form_validation->set_rules('email''Username''required|xss_clean');
        
$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());
                
                
                
$sql1 "SELECT login_fail_count FROM users WHERE username = ?"
                
$query1 $this->db->query($sql1$this->input->post('email'));
                
$loginfailcount '';                 
                  foreach(
$query1->result() as $row1)
                  
{
                      $loginfailcount 
$row1->login_fail_count;        
                  
}                
                    $data 
= array('login_fail_count' => $loginfailcount+1);
                    
$this->db->where('username'$this->input->post('email'));
                    
$this->db->update('users'$data);                
                
                
redirect($this->config->item('base_url_ssl').'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->load->view('login'$this->data);
        
}
    } 

I’m wondering why this seems to be working on my development system but not on the production environment. Thank you for your reply smile

 
Posted: 09 September 2011 02:17 PM   [ # 1088 ]   [ Rating: 0 ]
Joined: 2011-09-07
7 posts

Dear all,


I managed to resolve it already by replacing:

if (!$this->ion_auth->logged_in())
    
{
        
//redirect them to the login page
        
redirect('auth/login''refresh');
    

with:

if (!$this->ion_auth->logged_in())
    
{
        
//redirect them to the login page
        
$this->login();
    

This behavior seem strange but it worked for me. Thank you so much smile

 
Posted: 13 September 2011 03:50 PM   [ # 1089 ]   [ Rating: 0 ]
Joined: 2011-01-27
30 posts

Hello,

I installed ion_auth v2 but today I’m finally starting to use it. I uploaded the new files but I’m getting a lot of errors:

/auth

A PHP Error was encountered

Severity: Notice

Message: Undefined property: stdClass::$first_name

Filename: auth/index.php

Line Number: 18

/change_password

Fatal error: Uncaught exception ‘Exception’ with message ‘Undefined method Ion_auth::get_user() called’ in /home/volusia/public_html/application/libraries/Ion_auth.php:88 Stack trace: #0 /home/volusia/public_html/application/controllers/auth.php(120): Ion_auth->__call(‘get_user’, Array) #1 /home/volusia/public_html/application/controllers/auth.php(120): Ion_auth->get_user(‘1’) #2 [internal function]: Auth->change_password() #3 /home/volusia/public_html/system/core/CodeIgniter.php(339): call_user_func_array(Array, Array) #4 /home/volusia/public_html/index.php(202): require_once(’/home/volusia/p…’) #5 {main} thrown in /home/volusia/public_html/application/libraries/Ion_auth.php on line 88


Did I download the wrong package?

https://github.com/benedmunds/CodeIgniter-Ion-Auth

I click on ‘downloads’ and then clicked ‘zip’ under ‘download source’. Should I have downloaded a different package?

 
Posted: 13 September 2011 03:52 PM   [ # 1090 ]   [ Rating: 0 ]
Avatar
Joined: 2009-01-09
73 posts
$this->ion_auth->get_user() 
is gone. Use:
$this->ion_auth->user()->row() 

instead

 
Posted: 13 September 2011 04:13 PM   [ # 1091 ]   [ Rating: 0 ]
Joined: 2011-01-27
30 posts
spmckee - 13 September 2011 07:52 PM
$this->ion_auth->get_user() 
is gone. Use:
$this->ion_auth->user()->row() 
instead

Thanks, that did it. The only problem remaining is that my /auth page says there’s no first or last name when there is when I check phpmyadmin. Any ideas?

Edit: for reference, I looked in the auth.php file and its supposed to be pulling the data with this function:
$this->data[‘users’] = $this->ion_auth->users()->result();

 
Posted: 13 September 2011 04:19 PM   [ # 1092 ]   [ Rating: 0 ]
Avatar
Joined: 2009-01-09
73 posts

What code are you using to grab the first_name?

 
Posted: 13 September 2011 04:23 PM   [ # 1093 ]   [ Rating: 0 ]
Joined: 2011-01-27
30 posts

All of my pages are exactly what came with the git package:

<td><?php echo $user->first_name;?></td
 
Posted: 13 September 2011 04:36 PM   [ # 1094 ]   [ Rating: 0 ]
Avatar
Joined: 2009-01-09
73 posts

Setup your $user as

$this->user $this->ion_auth->user()->row(); 

Then just

echo $user->first_name 

See if that works.

 
Posted: 13 September 2011 04:46 PM   [ # 1095 ]   [ Rating: 0 ]
Joined: 2011-01-27
30 posts
spmckee - 13 September 2011 08:36 PM

Setup your $user as

$this->user $this->ion_auth->user()->row(); 

Then just

echo $user->first_name 

See if that works.

I’m not sure what I would change… here’s the code that generates the array:

//list the users
$this->data['users'$this->ion_auth->users()->result();
foreach (
$this->data['users'as $k => $user)
{
    $this
->data['users'][$k]->groups $this->ion_auth->get_users_groups($user->id);
}
    
$this
->load->view('auth/index'$this->data); 

Edit: a var_dump on var_dump($this->data); shows that there is no first or last name information in the results. Have these pages ever been tested? The /auth page has a table where all of the users are supposed to show, along with first name and last name, but the first name and last name aren’t being passed.

Edit 2: First and last name are in the meta table, and there’s nothing in the users() function to pull information from there. I’m wondering now if either I’ve downloaded the wrong package or I’m the first person in the world to actually use this.

Any ideas?

 
73 of 89
73