Welcome Guest, Not a member yet? Register   Sign In
flexi auth - A user authentication library for CodeIgniter

[eluser]Klausch[/eluser]
Hi,
Thanks for your quick reaction.
I tested it with your demo app and everything is working normally, and after loggin in with Remember Me, after closing the browser and reopening it, I am logged in automatically, as expected.
Als also the login method now shows ‘User logged in via “Remember me”’, so this works OK.

But in my app is still does not work.

My setting
'$config['sess_expire_on_close']
is indeed set to FALSE so this cannot be the problem.

I figured out the cookies after logging in with Remember Me:
login_via_password_token
user_id
remember_series
remember_token
ci_session

Which are the same as with your demo app after loggin in using Remember Me.

But... after closing the browser, reopen it and visit my site, I am not logged in.
The call to $this->flexi_auth->is_logged_in()
returns FALSE.

No no solution yet, any more ideas?

EDIT:
I put some debug messages in the is_logged_in() function, due to some redirects this function is called 3 times, and during the last call the user_identity is NULL:
ERROR - 2012-12-06 18:53:02 --> function is_logged_in()
ERROR - 2012-12-06 18:53:02 --> this->CI->auth->session_data[this->CI->auth->session_name['user_identifier']] = '[email protected]'
ERROR - 2012-12-06 18:53:03 --> function is_logged_in()
ERROR - 2012-12-06 18:53:03 --> this->CI->auth->session_data[this->CI->auth->session_name['user_identifier']] = '[email protected]'
ERROR - 2012-12-06 18:53:03 --> function is_logged_in()
ERROR - 2012-12-06 18:53:03 --> this->CI->auth->session_data[this->CI->auth->session_name['user_identifier']] = NULL
ERROR - 2012-12-06 18:53:03 --> Not logged in


EDIT:
Some more debugging gives the following, albeit still confusing information:
I have several Controller class which all extends MY_Controller. In the constructor of MY_Controller, the calls:
$this->auth = new stdClass;
$this->load->library('flexi_auth');
are made.


After closing the browser when looged in using "Remember Me" and reopening Firefox. I notice that the call to is_logged_in() is made during the load->library('flexi_auth') statement two times.
Apparently these calls originate from the Flexi_auth_lite constructor.

Both times it returns TRUE, and the right email address is found in the session.

But later in the constructor, the call to is_logged_in() returns FALSE.

Also, when visiting the site for the second time, only the first of the two calls to load->library('flexi_auth') return TRUE.

So.... this is really wierd! Any suggestions?
EDIT: This is probably explained in this comment:
/ If loading the 'complete' library, it extends the 'lite' library with additional functions,
// however, this would also runs the __construct twice, causing the user to wastefully be verified twice.
// To counter this, the 'auth_verified' var is set to indicate the user has already been verified for this page load.



EDIT:
In the constructor of Flexi_auth_lite, it appears that this test is passed:
if ($this->is_logged_in() && $this->CI->auth->auth_security['validate_login_onload'] && !isset($this->CI->flexi_auth_lite_model->auth_verified))

So the else-branch, containing the call:
$this->CI->flexi_auth_model->login_remembered_user();

is not reached. I think I am getting close to the culprit now...
How about the validate_login_onload property? It is set to TRUE in my config file.

EDIT:
I notice that the constructor code of Flexi_auth_lite (called by parent::__construct() in the constructor of Flexi_auth) is called twice. Immediately after each other.
I cannot see why that happens or understand whether this happens deliberately.
During some calls (apparently all calls except the first one after opening the browser), the this->CI->auth->session_data[this->CI->auth->session_name['user_identifier']] variable is empty in the second execution.
Strange stuff....

EDIT:
I carried out a test with validate_login_onload = FALSE,
Now the user is remembered after closing and re-opening the browser window. But.... this also happens when I do NOT select the "Remember Me" option!
This really makes me crazy... :-s


Messages In This Thread
flexi auth - A user authentication library for CodeIgniter - by El Forum - 12-06-2012, 06:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB