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 - 04-01-2013

Hi Rob,

thank you for your brilliant codes.

I am using the demo codes, it come out errors relative to the tables. For instant below, select the uadd_id, this field is not in the user_accounts table it is in the demo_user_address table.
Is there any problem that I did not get the correct codes from you website. I did download the zip files from github.

Many thanks

A Database Error Occurred

Error Number: 1054

Unknown column 'uadd_id' in 'field list'

SELECT `uadd_id`, `uadd_alias`, `uadd_recipient`, `uadd_company`, `uadd_post_code` FROM (`user_accounts`) LEFT JOIN `user_groups` ON `user_accounts`.`uacc_group_fk` = `user_groups`.`ugrp_id` WHERE `uadd_uacc_fk` = '1'

Filename: C:\server\Apache Software Foundation\Apache2.2\ci\system\database\DB_driver.php

Line Number: 330

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

[quote author="ranggadablues" date="1358045217"]Hi, your library was so great. But I'm have a little trouble here about send email for new user registration from localhost. I already change on
to my gmail setting.

the trouble is,
first from demo flexi auth it's not show any message after success registration, but the data success insert to database.
second I can't find any email on my gmail inbox?

so, did I missed any configuration?

thank you in advance[/quote]

First off.....AWESOME LIBRARY!!! Exactly what I needed. I'm a newb to CI and handjammed my first CI project's authentication with just basic login/logout permission capabilities. Started a new CI project over the weekend from scratch with your library and so far freakin love it. KUDOS! All right... enough flattery.....

I'm running my dev environment on my mac using MAMP. I ran into the same issues ranggadablues did with getting the email functions to work properly. I remembered I ran into the same issue with my first CI project and the simple fix was adding a linebreak to the email config parameter:


If you don't.....the script will just hang. I added this to the flexi_auth_model.php just before the other email config parameters around line 2309'ish and can now send emails without needing to install any mail server. Hope this helps. I'm sorry if this fix was already identified.

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

Hi!, first very thanks for this very usefull library, I use this for default in mysql I and dont have problems, but one of the requeriments is that the app work over PostgreSQL, I made a migration from mysql and I config the database.php

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'postgres';
$db['default']['password'] = '';
$db['default']['database'] = 'test';
$db['default']['dbdriver'] = 'postgre';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;

But this return a blank page, this library support PostgreSQL?

EDIT: i change my server and this support postgreSQL, but is really a pity that this auth have a lot ofs incongruencies with Postgre this is one of them:

ERROR: column "user_accounts.uacc_email" must appear in the GROUP BY clause or be used in an aggregate function

SELECT "uacc_id", "uacc_email", "uacc_suspend", "ugrp_name", "upro_first_name", "upro_last_name" FROM "user_accounts" LEFT JOIN "user_groups" ON "user_accounts"."uacc_group_fk" = "user_groups"."ugrp_id" LEFT JOIN "demo_user_profiles" ON "user_accounts"."uacc_id" = "demo_user_profiles"."upro_uacc_fk" LEFT JOIN "demo_user_address" ON "user_accounts"."uacc_id" = "demo_user_address"."uadd_uacc_fk" GROUP BY "uacc_id"

When I List the "manage users" after login Sad


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

I've updated the database dump files to included default values for all database columns. Hopefully this should fix the issue you and @taztwister have been having.

Regarding the 'uadd_id' error message you have reported, I would need to know more details on the implementation of your code and what function was generating the error. I'm guessing this is most likely a setup configuration problem rather than a library issue.

Thanks for posting a solution to this problem, I've now included the change within the library repo.

I've never tested the library with Postgresql, but I believe other users have also run into issues that are out of the scope of me having time to look into and fix.

If you wish to use the library, you are best off using the tried and tested MySQL.

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

Good morning.

I'm trying to introduce flexi auth into my project, and I'm getting stuck in this:

Fatal error: Class 'Flexi_auth_lite_model' not found in C:\wamp\www\corneta\application\models\flexi_auth_model.php on line 37

I'm running a WAMP instalation, windows 7, php 5.4.3, CI 2.1.3, mysql 5.5.24;

I saw on the files of the library that you made a "load_class('Flexi_auth_lite', 'libraries', FALSE);", and I tried it on the flexi_auth_model.php, like this: "load_class('Flexi_auth_lite_model', 'models', FALSE);", and it worked, showing me this time the error of:

"A PHP Error was encountered

Severity: Warning

Message: Creating default object from empty value

Filename: models/flexi_auth_lite_model.php

Line Number: 47".

I have this lines arlready in CI_Controller :
$this->auth = new stdClass;

Thank you.

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

Hey Rob.

I am trying to do a mass insert (via a for loop) to do some data migration. Anything I should take note of ? I'm hitting errors like duplicate usernames when username is not my identity column!

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


There shouldn't be anything that you need to change within any of the model or library files in order to get the auth library working.
You environment setup for php/CI version etc. looks to be good (Pretty much the same as mine), so that shouldn't be the problem.

The best I can suggest is that you install a brand new version of CI, and then add the flexi auth demo example.
Make sure all the core library files and demo files have been merged correctly into the one installation.

If you can get this working on a clean installation, then try and work out what the differences are between the setups.
You've probably already followed this guide, but there is an installation guide at



I'm presuming you're already doing this, but you must ensure that when inserting users to the database that you use the libraries own functions. The reason being is that the password is set and verified by the library using its own hashing techniques, if you just try and insert the password using another function, you're likely to run into issues there.

Furthermore with the passwords, ensure you set the static salt within the library config file to what you want it to be, otherwise all inserted user passwords will be using the salt that you have since changed.

Regarding the duplicate username issue, regardless of whether you're using the username column as the primary identity column, it still needs to be unique. You're unlikely to want multiple users with the same username - but in the case that you do have identical usernames, you will need to add a new custom column to the table and then use that column instead.

You may also want to ensure that the users are added to specific user groups and that their accounts are automatically activated upon insertion.

Any other problems?

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

Thanks for the quick reply rob.

To give you some background - I have only set email as the unique column, so, username can be the same.

When I insert a user, this portion of the code seems to suggest that regardless of whether my username column is unique or not, it will check for duplication.

Take a look at this code found in flexi_auth_model.php line 125 onwards:

// If username is the primary identity column, check it is unique.
  // If it isn't unique, auto incrementing the username (See next 'if' condition) cannot be used, as user must know their new username to login.
  if ($this->auth->primary_identity_col == $this->auth->tbl_col_user_account['username'] && !$this->identity_available($username))
   $this->set_error_message('account_creation_duplicate_username', 'config');
   return FALSE;
  // Auto increment duplicate usernames (username1, username2...) if defined by config file.
  else if (!empty($username) && !$this->username_available($username))
   if ($this->auth->auth_settings['auto_increment_username'])
    $check_username = $username;
    for($i = 0; !$this->username_available($check_username); $i++)
     $check_username = ($i > 0) ? $username.$i : $username;
    $username = $check_username;
   // Require user to try another username.
    $this->set_error_message('account_creation_duplicate_username', 'config');
    return FALSE;

if ($this->auth->primary_identity_col == $this->auth->tbl_col_user_account['username'] && !$this->identity_available($username))

Firstly, this will fail since I did not set username as my primary identity column.

It will then go into

else if (!empty($username) && !$this->username_available($username))

Since username is not empty, it will definitely run username_available.

Username available code from line 908:
public function username_available($username = FALSE, $user_id = FALSE)
     if (empty($username))
   return FALSE;
  // Try and get the $user_id from the users current session if not passed to function.
  if (!is_numeric($user_id) && $this->auth->session_data[$this->auth->session_name['user_id']])
   $user_id = $this->auth->session_data[$this->auth->session_name['user_id']];

  // If $user_id is set, remove user from query so their current username is not found during the duplicate username check.
  if (is_numeric($user_id))
   $this->db->where($this->auth->tbl_col_user_account['id'].' != ',$user_id);

  return $this->db->where($this->auth->tbl_col_user_account['username'], $username)
   ->count_all_results($this->auth->tbl_user_account) == 0;

This function will always check if the username already exist in the table. Although it is specified in the config, it is not used here to check if username column SHOULD be a unique column.

Take a look at this:
return $this->db->where($this->auth->tbl_col_user_account['username'], $username)
   ->count_all_results($this->auth->tbl_user_account) == 0;

In my config file:
  * Primary User Identity Column
  * Set the column to be used to primarily identify users.
  * Note: The column MUST be either the ['email'] or ['username'] columns from the main user account table, and must contain a unique column name.
$config['database']['settings']['primary_identity_col'] = 'uacc_email';

Hope this clarifies!

On the same note, since I am looping, I realized once I hit an error (duplicate email), the rest will not continue to insert? How can I continue doing it ?

Edit: Oops, I just saw that you mentioned that username has to be unique!

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

thank you for the great lib

i think there is a bug

when you login using password and you close the browser then you reopen it you will find you are still logged in even you did not use "Remember me" feature

only you should be logged in when you select remember me else when you close the browser it does not clear the cookies for "login_vie_password_token"

i tried the demo online so i think there is a bug

thank you in advance

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

Hello again,

I am getting this error whenever a user tries to reset their password and I don't know why..

Your submitted password token is invalid or has expired.

Any ideas?

Thanks in advance