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

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Libraries & Helpers (
+--- 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 - 02-18-2013

Also I don't want the demo I just want to create my own users what I need to do?

flexi auth - A user authentication library for CodeIgniter - El Forum - 02-20-2013


I've never used CI Datamapper and the flexi auth library was never designed to work with it.
If you give it a try yourself, I and I'm sure other users, would be interested to hear your results whether successful or not.


Unfortunately the library is not compatible with the CI autoload function as the global $this->auth = new stdClass; needs to be defined prior to loading the library.

To get around this, I personally define a Controller extension named MY_Controller with CI 'application/core' (See:, I then manually load the library within that one controller, which then can then be loaded by all of your other controllers - in effect acting as an autoloader.

Regarding how to get started without the demo.
First off, before you start anything, ensure you have setup you flexi auth config as you want - defining your own salt keys etc (see the manual @

Then create a form to register your first user - see the register_account() method defined within the demo_auth_model.php file for examples.
Users must be created using the library rather than manually entering details into the database as the users password needs to be hashed correctly.

That should give you a start on adding users to your application.

flexi auth - A user authentication library for CodeIgniter - El Forum - 02-20-2013

Hi haseydesign,

First of all thanks for contributing this great authentication library!

I was going over the function get_user_group_privileges() function to retrieve all the privileges of the current logged in user and his group_privileges. I have set up the code like this:

$this->data['privileges'] = $this->flexi_auth->get_user_group_privileges()->result();

This gives the following SQL error:

Unknown column 'Array' in 'where clause'

SELECT * FROM (`user_privileges`) JOIN `user_privilege_groups`
ON `user_privileges`.`upriv_id` = `user_privilege_groups`.`upriv_groups_upriv_fk`
WHERE `user_privilege_groups`.`upriv_groups_ugrp_fk` = Array

Filename: /Users/ovvessem/Sites/mobius360_ci/models/flexi_auth_model.php

Line Number: 1502

Looking at the get_user_group_privileges_query function in Flexi_auth.php I notice the following:

if (! $sql_where)
$sql_where = array($this->CI->auth->tbl_col_user_privilege_groups['group_id'] =>

The session variable group contains a key and value of the group (ID and Group name). I have solved it by placing the session_data within the key() function like so:

$sql_where = array($this->CI->auth->tbl_col_user_privilege_groups['group_id'] =>

Is this a 'bug' or am I using the function in a wrong way?

flexi auth - A user authentication library for CodeIgniter - El Forum - 02-22-2013


Thanks for pointing this issue out.
User group privileges is the newest feature to be added to the library so has not gone through that same level of testing as most other features.

I've fixed the bug as you outlined yourself and have push it to the Github repo with a credit in your name.

Thanks again!

flexi auth - A user authentication library for CodeIgniter - El Forum - 02-24-2013

Quote:i have tested many time for this when i login with remember me,
after i close the browser, and reopen the browser, it will logout all sessions.

@tonyhk via Github -

This currently seems to be working fine for me in Chrome and FF.

So you can test yourself, I have 'temporarily' changed the live demo so that the config setting 'logout_user_onclose' = FALSE.

To test, do the following:
1: Login with 'Remember Me' checked @
2: Check your login status @ (You should be logged in)
3: Close your browser completely - not just the tab.
4: Reopen the browser @
5: You should be still logged in via 'Remember Me'

The important setting you have to ensure are set is the $config['security']['logout_user_onclose'] = FALSE; within the flexi auth config file.
The other important setting is $config['sess_expire_on_close'] = FALSE; within the CI config file.

flexi auth - A user authentication library for CodeIgniter - El Forum - 03-01-2013

Can you please let me know how to disable new user registration?

flexi auth - A user authentication library for CodeIgniter - El Forum - 03-01-2013


Unless there is something I'm misunderstanding, by not building a registration page on your website, no one would be able to register for an account on your website - no?

flexi auth - A user authentication library for CodeIgniter - El Forum - 03-03-2013

Great plugin! Big Grin

I'm going to use it for the public end-users in my application. The administrator backend and user front-end is two seperated databases.
I will need the functions to be available from my admin application as well, so how do I define that flexi-auth should use another database, than the default one?

(I wasn't able to find this in the user docs, installation guide, or config file).

I attempted this:
        //$DB1 = $this->load->database('market', TRUE);

        $data['query'] = $this->db

But it didn't seem to work as I get those:
Table 'admincp.user_accounts' doesn't exist (wrong db)
Message: Creating default object from empty value

Filename: models/flexi_auth_lite_model.php (I assume it's because it's loading the wrong db)

flexi auth - A user authentication library for CodeIgniter - El Forum - 03-04-2013

Does Flexi Auth work with Postgresql? Because of company/department standards I need to use Postgresql and before embarking on integrating your nice looking auth library into own new site(s), I would like to know if this is possible.

I know from looking at your sql I am going to have to do some changing of your tables. Have you ever thought about using the built in Migration tools to generate the database so that its a config setup and then run a command on the database to create the tables? This way it also gives a start for migrating a site over time.

I have done a first try on the sql, but before I even get that far I am getting errors from flex_auth_lite_model.php for three PHP errors (2 warnings and 1 notice)

Line 64: Invalid argument supplied for foreach() - Warning
Line 693: Invalid argument supplied for foreach() - Warning
LIne 701: Undefined property: stdClass::$session_data -Notice

System is php: 5.1.6 CI: 2.1.3 DB: postgresql 9.1(8.1 php drivers)

Only features I have used so far are the
$this->auth = new stdClass();
in MY_Controller class constructor.

Thanks for the help and the library.

flexi auth - A user authentication library for CodeIgniter - El Forum - 03-05-2013


You seem to be suggesting that your site will have two databases, one used for the front end, and one used for the backend.
However, you then wish to use the flexi auth library on both the front and back end of your site - am I understanding that correctly?

Which database do you wish to hold all of the flexi auth tables in? As you obviously can't keep them in both databases.

The library was not designed with this scenario in mind, and so the library is looking to use the default database, which is going to cause you troubles.
May I suggest another option; if you must have the 2 databases split, rather than as one, then why not include the flexi auth tables into another 3rd database. This 3rd database would actually be CI's default database and so all calls to it 'should' work without having to reconfigure any of the library code.

Would this be possible with your setup?



I've not tested the library with Postgresql and I have not heard from any other users using it, therefore I cannot say whether it will work.

You mention the only features you have implemented are:
$this->auth = new stdClass();

Have you also ensured that you have completed the other steps outlined via the installation guide (