benedmunds / CodeIgniter-Ion-Auth

Simple and Lightweight Auth System for CodeIgniter
http://benedmunds.com/ion_auth/
MIT License
2.34k stars 1.14k forks source link

ion_auth_model.php can't make use of Session library #61

Closed cezarykluczynski closed 13 years ago

cezarykluczynski commented 13 years ago

After almost successfully logging in as default user (admin@admin.com), i get this error:

Call to a member function set_userdata() on a non-object in /path/to/application/models/ion_auth_model.php on line 606

which points here:

https://github.com/benedmunds/CodeIgniter-Ion-Auth/blob/master/models/ion_auth_model.php#L605

It is my understanding that Session library has been loaded once by class Ion_auth and every next attempt to load it is skipped (that what logs says), so it's not being referenced in Ion_auth_model. Gettype($this->session) near line 605 in ion_auth_model.php returns null.

I'm using latest version of Ion Auth from May 18th and CodeIgniter 2.0.2. Ion Auth is auto-loaded in autoload.php. I also have hook at post_controller_constructor and all it does is running

$this->load->database();

because otherwise Ion Auth coudn't connect to the database, which might be another issue.

benedmunds commented 13 years ago

Not to say this is the solution, but what do you get if you autoload the session and db?

cezarykluczynski commented 13 years ago

I've tried that. That's the another issue mentioned at the end of last post. When this is done

$autoload['libraries'] = array('database', 'session', 'ion_auth');

I get:

Call to a member function where() on a non-object in /path/to/application/models/ion_auth_model.php on line 342

when subbmiting login form.

benedmunds commented 13 years ago

Pull and see what you get now with both loading manually and autoloading. I just pushed this commit: http://github.com/benedmunds/CodeIgniter-Ion-Auth/commit/1b5527cf190e1450804b7af2ff9f1e1ce46e4ccf

cezarykluczynski commented 13 years ago

Nope, that's doesn't help either. Commenting out first statement from identity_check() just does nothing, as $ion_auth->_extra_where doesn't seems to be declared anywhere, and commenting out second statement makes login() to fail because of !$this->identity_check($identity) at line 574.

Here's where I get so far: when object from Ion_auth_model is constructed, gettype($this->session) returns object both prior and after

$this->load->library('session');

Log says it was a second attempt to load Session and it's omitted. However by the time it gets to login(), gettype($this->session) returns null in both Ion_auth_model and Ion_auth library, so even putting something like

function set_session_userdata($userdata) { $this->ci->session->set_userdata($userdata); }

at the end of Ion_auth library and then calling it from model results in

Call to a member function set_userdata() on a non-object

It makes sense to assume that reference to session is nullified somewhere along the way, but I'm not that deep into CodeIgniter (that's my third day with it) to start guessing where.

benedmunds commented 13 years ago

What version of CI are you using? Send me a link to the commit please.

cezarykluczynski commented 13 years ago

It's 2.0.2 from codeigniter.com, this one I think: https://bitbucket.org/ellislab/codeigniter-reactor/src/521076012037

benedmunds commented 13 years ago

Package up and email me your whole project please (controllers, models, views, etc.) ben.edmunds@gmail.com

benedmunds commented 13 years ago

Haven't heard back so I'm closing this. Feel free to open another one and email me if you still need help. Thanks!