Welcome Guest, Not a member yet? Register   Sign In
Ion Auth - Lightweight Auth System based on Redux Auth 2

[eluser]joytopia[/eluser]
[quote author="Iversia" date="1290210703"]Bernd, I'm getting the exact same error when using Ion Auth and the latest tip version of CI2.

Maybe they've changed the load order? The version from ~October 12 was working fine.[/quote]

Iversia, Devon,
thanks for reporting the same error.
I downloaded the newest CI2 from tip, but unfortunately the error remains (sometimes you have to reload the page up to 7 times to reproduce the error).

Could someone please send me an old Version of CI2 , perhaps from around ~October 12, than I can try, if it works with that version?

Thanks and best regards
Bernd

[eluser]Devon Lambert[/eluser]
[quote author="joytopia" date="1290515512"][quote author="Iversia" date="1290210703"]Bernd, I'm getting the exact same error when using Ion Auth and the latest tip version of CI2.

Maybe they've changed the load order? The version from ~October 12 was working fine.[/quote]

Iversia, Devon,
thanks for reporting the same error.
I downloaded the newest CI2 from tip, but unfortunately the error remains (sometimes you have to reload the page up to 7 times to reproduce the error).

Could someone please send me an old Version of CI2 , perhaps from around ~October 12, than I can try, if it works with that version?

Thanks and best regards
Bernd[/quote]

Hey Bernd,

See below:

UPDATE ON THE UNDEFINED/MODEL Error

After beating my head against a wall trying to figure out a fix for the error that Bernd, Inversia, and myself have been experiencing, I made the following change to the Model.php file under the CI Core (I know, this seems a bit hackish, but if I'm correct, I believe this minor fix should be pushed to the core anyways).

CI > System > Core > Model.php

Change this function:
Code:
function __get($key)
    {
        $CI =& get_instance();
        return $CI->$key;
    }


To this:
Code:
function __get($key)
    {
        $CI =& get_instance();
        
        if (isset($CI->$key)) {
            return $CI->$key;
        }
    }

I believe the error is returned because CI is trying to make recursive use of __get with the Ion_auth class. i.e. Controller calls Library, Library calls Model. etc...

Hope this helps someone else out there. :-)

[eluser]kakap[/eluser]
hello, I need help here in using ci+hmvc+ion auth. my simple codes :

MY_Controller: (location:application/libraries/MY_Controller.php)
Code:
<?php (defined('BASEPATH')) OR exit('No direct script access allowed');

class MY_Controller extends Controller{
    
    function __construct() {
        
        parent::Controller();
        
    }
}

Admin_Controller: (location:application/libraries/Admin_Controller.php)
Code:
<?php (defined('BASEPATH')) OR exit('No direct script access allowed');

class Admin_Controller extends MY_Controller{
    
    function __construct() {
        
        parent::__construct();
        
        //check apakah user login
        if (!$this->ion_auth->logged_in()) {
            
            //jika belum login kirim ke halaman login admin
            redirect('admin/login', 'refresh');
        }
        //cek apakah yang login adalah admin
        elseif (!$this->ion_auth->is_admin()) {
            
            //jika yg login bukan admin (user biasa) maka
            //dikembalikan ke halaman profil siswa.
            redirect('siswa/index', 'refresh');
        }
    }
}

admin.php: (location:application/controller/admin.php)
Code:
<?php (defined('BASEPATH')) OR exit('No direct script access allowed');

class Admin extends Admin_Controller{
    
    function __construct() {
        
        parent::__construct();
        $this->load->library('form_validation');
    }
    
    function index() {
        
        //here
        $this->data['title'] = 'Dashboard';
        
        $this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
        $this->data['users'] = $this->ion_auth->get_users_array();
        
        $this->load->view('admin/index', $this->data);
    }
    
    function login() {
        
        //here
        $this->data['title'] = 'Login';
        
        //validasi input
        $this->form_validation->set_rules('email', 'Email', 'required|valid_email');
        $this->form_validation->set_rules('password', 'Password', 'required');
        
        if ($this->form_validation->run() == TRUE) {
                
            //cek remember me
            if ($this->input->post('remember') == 1) {
                
                $remember = TRUE;
            }
            else {
                
                $remember = FALSE;
            }
            
            if ($this->ion_auth->login($this->input->post('email'), $this->input->post('password'), $remember)) {
                
                $this->session->set_flashdata('message', $this->ion_auth->messages());
                redirect('admin/index', 'refresh');
            }
            else {
                
                $this->session->set_flashdata('message', $this->ion_auth->errors());
                redirect('admin/login', 'refresh');
            }
        }
        else {
            
            //disini adalah antarmuka login
            //$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('admin/login', $this->data);
        }
    }
    
    function logout() {
        
        //here
        $this->data['title'] = 'Logout';
        
        $logout = $this->ion_auth->logout();
        redirect('admin/login', 'refresh');
    }
}

?>

when I try to access http://localhost/web/admin/login, the page refresh on and on (I mean always refreshed) I think this is because the condition from Admin_Controller :
Code:
//check apakah user login
        if (!$this->ion_auth->logged_in()) {
            
            //jika belum login kirim ke halaman login admin
            redirect('admin/login', 'refresh');
        }

I want to ask, how to pass it from the condition ?. I try to see from PyroCMS Admin_Controller, there is stuff like :
Code:
// These pages get past permission checks
        $ignored_pages = array('admin/login', 'admin/logout');
            
        // Check if the current page is to be ignored
        $current_page = $this->uri->segment(1, '') . '/' . $this->uri->segment(2, 'index');
        $is_ignored_page = in_array($current_page, $ignored_pages);

but I don't know how to make my own code like that.

help me please, thank yo so much.

[eluser]woeps[/eluser]
Hey Kakap!
I'm not an expert on CI but I think your problem could be the constructor of your Admin_Controller...
[quote author="kakap" date="1290580595"]
Code:
<?php (defined('BASEPATH')) OR exit('No direct script access allowed');

class Admin_Controller extends MY_Controller{
    
    function __construct() {
        
        parent::__construct();
        
        //check apakah user login
        if (!$this->ion_auth->logged_in()) {
            
            //jika belum login kirim ke halaman login admin
            redirect('admin/login', 'refresh');
        }
        //cek apakah yang login adalah admin
        elseif (!$this->ion_auth->is_admin()) {
            
            //jika yg login bukan admin (user biasa) maka
            //dikembalikan ke halaman profil siswa.
            redirect('siswa/index', 'refresh');
        }
    }
}
[/quote]
On every call of the admin controller you check first if the user is logged in. (At this time the user hadn't even a chance to login.) And if he is not logged in you redirect him again to admin/login. So I think this is where your controller "loops".. at least you have to expand the if-statement to check if the actual location is not "admin/login" yet.
For example:
Code:
<?php (defined('BASEPATH')) OR exit('No direct script access allowed');

class Admin_Controller extends MY_Controller{
    
    function __construct() {
        
        parent::__construct();
        
        //check apakah user login
        $current_page = $this->uri->segment(1).'/'.$this->uri->segment(2);
        if (!$this->ion_auth->logged_in() && $current_page != 'admin/login') {
            
            //jika belum login kirim ke halaman login admin
            redirect('admin/login', 'refresh');
        }
        //cek apakah yang login adalah admin
        elseif (!$this->ion_auth->is_admin()) {
            
            //jika yg login bukan admin (user biasa) maka
            //dikembalikan ke halaman profil siswa.
            redirect('siswa/index', 'refresh');
        }
    }
}
I hope this works! Wink

__________________________________________________________________


My (own) Problem:
Every time when I try to use the username_check()-method I get this sql-error:
Quote:A Database Error Occurred

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `username` = 'administrator'' at line 2

SELECT COUNT(*) AS `numrows` WHERE `username` = 'administrator'


my code is pretty simple (stripped down):
Code:
function register()
        {
        $this->load_form_validation(); //Validation-Rules are set in the config-file
        if($this->form_validation->run() && !$this->ion_auth->username_check($this->input->post('username'))
            {
            //do register
            $this->messages->add('REGISTER-ACTION!', 'debug');
            }
        else
            {
            $this->errOp(); //output the errors
            $this->data['cont'] = $this->get_view('auth/register'); //load registration-form
            }
        $this->output(); //Output everything
        }

any idea where should I look for my error?

I have a MY_Controller but it contains only a few methods I use more often and in the header I set a few default-values for vars.
without the username_check()-call everything works fine..

I updated the ion-auth-library today but this didn't help either.
(I use CI version 1.7.2)

Thanks for your help!

[eluser]joytopia[/eluser]
Hey Devon,

thank you so much! It seems that the error has gone.

Now I wonder if one of us should report that issue at bitbucket or if one of the core team, Ben?, Phil? can fix it directly?

Best regards
Bernd

[eluser]Devon Lambert[/eluser]
[quote author="joytopia" date="1290606201"]Hey Devon,

thank you so much! It seems that the error has gone.

Now I wonder if one of us should report that issue at bitbucket or if one of the core team, Ben?, Phil? can fix it directly?

Best regards
Bernd[/quote]

Done

[eluser]Todlerone[/eluser]
Hello everyone. I'm trying to use this but when I enter the MySql information I get the error:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTITY(1,1),
group_id int NOT NULL,
ip_address char(16) NOT NULL,
' at line 2

Any suggestions?

TY in advance. SOLVED...turns out I used the mssql by mistake.

[eluser]kakap[/eluser]
Quote:
Code:
<?php (defined('BASEPATH')) OR exit('No direct script access allowed');

class Admin_Controller extends MY_Controller{
    
    function __construct() {
        
        parent::__construct();
        
        //check apakah user login
        $current_page = $this->uri->segment(1).'/'.$this->uri->segment(2);
        if (!$this->ion_auth->logged_in() && $current_page != 'admin/login') {
            
            //jika belum login kirim ke halaman login admin
            redirect('admin/login', 'refresh');
        }
        //cek apakah yang login adalah admin
        elseif (!$this->ion_auth->is_admin()) {
            
            //jika yg login bukan admin (user biasa) maka
            //dikembalikan ke halaman profil siswa.
            redirect('siswa/index', 'refresh');
        }
    }
}
I hope this works! Wink

yes, thats worked. thank you.
but, I need page 'admin/logout' should be passed too. so I modified it lilte. Smile

[eluser]Todlerone[/eluser]
Hello all. Sorry if this is a very basic question but I made a mess trying to make it work. All I want to do is have the login form from my main page. I don’t want a link to send me to another login page.

TY in advance

[eluser]techgnome[/eluser]
So then include the login form as part of your view. There's nothing that says the login form has to be it's own view. Just make sure the form posts to the right controller, and if it fails that it redirects to an appropriate page.

-tg




Theme © iAndrew 2016 - Forum software by © MyBB