CodeIgniter Forums
flexi auth - A user authentication library for CodeIgniter - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forum-22.html)
+--- Thread: flexi auth - A user authentication library for CodeIgniter (/thread-54581.html)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34


flexi auth - A user authentication library for CodeIgniter - El Forum - 12-05-2012

[eluser]jimsefton[/eluser]
[quote author="haseydesign" date="1354612588"]Hey Jim,
I think these forums have developed a few problems with their notification and private message system no longer working.

Can you zip your flexi auth application folder and email it to me at flexiauth [at] haseydesign [dot] com.
I'll try having a look at it for you.

Rob[/quote]

Hi Rob,

Thanks. I had deleted the installation, so I installed it again and it now appears to be working. Not sure what was different.

I did have a few issues in that I'd added flexi_auth to the autoload file and it didn't like that. Now I removed that and just have database and session libraries autoloaded.

Anyway, seems to be working now, hopefully it'll be a bit smoother from here on in.

Thanks,

Jim

P.S. Yeah, these forums are a mess... pagination doesn't seem to work in some browsers and PM's are going astray... doesn't give much confidence in the CodeIgniter framework, does it?!


flexi auth - A user authentication library for CodeIgniter - El Forum - 12-05-2012

[eluser]jimsefton[/eluser]
Hi again,

I spotted a small error in your demo files. In the user_group_insert_view.php file you have the description field name set to "update_group_description" instead of "insert_group_description".

Other than that am getting on with it fine.

Cheers,

Jim


flexi auth - A user authentication library for CodeIgniter - El Forum - 12-05-2012

[eluser]Klausch[/eluser]
Hi,

We are using the framework now for some time and still grald with it!
But, I miss the point with the Remember Me option when logging in. In my view, this should take care of remaining logged after a browser closure or computer shutdown.
A bit like some email providers work, when I log in to Yahoo, I do not need to enter my credentials until I explicit log out or log in from another machine.

But even when selecting Remember Me, I need to re-enter my credentials after having closed the browser (Firefox). Also the Demo application shows this behaviour.
Am I missing something or is this a (known) issue?

N.B. The following line is set:
$config['security']['logout_user_onclose'] = FALSE;


flexi auth - A user authentication library for CodeIgniter - El Forum - 12-06-2012

[eluser]haseydesign[/eluser]
@jimsefton
Thanks for the good use of your eagle eye there Jim.
I'll make the changes on that very soon.

@Klausch
To test whether this is a bug with your version of FF, I've temporarily updated the live demo @ http://haseydesign.com/flexi-auth/auth so that the 'logout_user_onclose' also equals false.
Code:
$config[‘security’][‘logout_user_onclose’] = FALSE;

Can you please login to the demo using FF (With 'remember me' checked) and then close your browser, then reload the site on page http://haseydesign.com/flexi-auth/auth_lite/privilege_examples.

The login method should go from 'User logged in via password' before close to 'User logged in via "Remember me"'.
Whilst the user is still logged in, they haven't validated their credentials via a password during this session, therefore, you can decide whether you wish to force the user to properly enter their password before performing specific actions within their account - for example, they must login properly before changing their email address.

For my version of FF (v15), this works fine.
If your own implementation is automatically logging you out, then maybe you have the native CI config option 'sess_expire_on_close' set to true (application/config.php). It needs to be like the following.
Code:
'$config['sess_expire_on_close'] = FALSE;

HTH


flexi auth - A user authentication library for CodeIgniter - El Forum - 12-06-2012

[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']] = 'klausch68@gmail.com'
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']] = 'klausch68@gmail.com'
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


flexi auth - A user authentication library for CodeIgniter - El Forum - 12-11-2012

[eluser]haseydesign[/eluser]
@Klausch,
Oh man, it sounds like been on a mission to the depths of hell and haven't found your way back out yet.

Sadly, I can't give you a quick fix on what your problem is, as it obviously sounds like you've got the library already fully wired into your new site. This means there could any number of configs that could be conflicting with the library, which is going to be unique to your setup.

I can confirm that on the current live demo site, the config setting 'validate_login_onload' = TRUE.

Personally what I would do in your situation is create a clone copy of your existing CodeIgniter setup and start rebuilding your setup piece-by-piece to identify the culprit.

First off, copy the flexi auth demo to your existing application folder and check whether it works on your own server.
Provided it does, then you know the library does indeed work on your server.

Next, create a new controller and views that allow you to simply login and then display your login credentials and permissions.
If this page works, then start to rebuild your controller setup to include the other code, libraries and models in your existing setup.

Eventually, something is going to break it, and there will be the main lead to what your problem is.

I hope that helps you out. Keep us posted.


flexi auth - A user authentication library for CodeIgniter - El Forum - 12-11-2012

[eluser]Unknown[/eluser]
Love your work. Please consider adding Facebook and Twitter authentication.


flexi auth - A user authentication library for CodeIgniter - El Forum - 12-13-2012

[eluser]katanama[/eluser]
Hello Rob,

Nice library you've got here.... I like it very much. Easy to use too.

Got a few questions for you mate...

1. Have you ever tried Flexi-Auth with HMVC?

2. I'm trying it with HMVC and got the "Creating default object from empty value" warning... just a warning but extremely annoying.

here's the full error

Code:
A PHP Error was encountered

Severity: Warning

Message: Creating default object from empty value

Filename: models/flexi_auth_lite_model.php

Line Number: 47

On my controllers' constructor I already have it like this :

Code:
// Load required CI libraries and helpers.
            $this->load->database();
            $this->load->library('session');
            $this->load->helper('url');
            $this->load->helper('form');

            // This is used as a global that is accessible via both models and both libraries, without it, flexi auth will not work.
            $this->auth = new stdClass;
            

            // Load 'standard' flexi auth library by default.
            $this->load->library('flexi_auth');

CI : v2.1.3
HMVC : I don't know what version but it's the latest stable. downloaded two days ago.
Flexi Auth : Latest...


flexi auth - A user authentication library for CodeIgniter - El Forum - 12-13-2012

[eluser]katanama[/eluser]
I got rid of the warning...

My controller for my login page is a class named Auth.

That could be one of the cause. Because when using that page, for sure the controller will be instantiated and within the controller itself the stdObject Auth will be attempted for instatiation.

However, another controller that load Flexi Auth, a controller class called Users, also have the same problem.


Solution :

I created a file named Auth.php inside /application/libraries
Content of that file is simply:

Code:
<?php

class Auth {}

and then inside my controllers constructor I have this :

Code:
// Load required CI libraries and helpers.
            $this->load->database();
            $this->load->library('session');
            $this->load->helper('url');
            $this->load->helper('form');

            // This is used as a global that is accessible via both models and both libraries, without it, flexi auth will not work.
            $this->load->library('auth');
            

            // Load 'standard' flexi auth library by default.
            $this->load->library('flexi_auth');

Simply load it using MX_Loader or CI_Loader (depends wether one uses HMVC) by using


Code:
$this->load->library('auth')

It's not pretty, but it does take the eyesore away.



flexi auth - A user authentication library for CodeIgniter - El Forum - 12-13-2012

[eluser]haseydesign[/eluser]
Hey katanama,

I've not tried using the flexi auth library with HMVC so I was unaware of the potential conflicting issues that you've had.
I've unfortunately not got the time at the moment to have a go at coming up with a solution myself, but your solution seems like a good band-aid fix in the meantime.

Also, awesome work on posting your solution back to help others with the same problem in the future.