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

Some issues about the data model:

CREATE TABLE `user_accounts` (
PRIMARY KEY (`uacc_id`),
UNIQUE KEY `uacc_id` (`uacc_id`),

This is what I meant by a redundant unique index, a field which is defined as primary key is unique by definition, so the UNIQUE KEY constraint is superfluous.
This is also found in some other tables.

A potential more severe problem is:

CREATE TABLE `user_privilege_users` (
`upriv_users_id` smallint(5) NOT NULL AUTO_INCREMENT,
`upriv_users_uacc_fk` int(11) NOT NULL,
`upriv_users_upriv_fk` smallint(5) NOT NULL,
PRIMARY KEY (`upriv_users_id`),

First, I do not see the added value of an auto increment key in a link table. The combination of both FK field is already unique and perfectly suitable as primary key.
Worse, the upriv_users_id PK field, if used, should not be a smallint. One of the foreign key fields refers to the User Account table and because each user can have more privileges, the potential number of entries of this link table is higher than the number of users.
So IF a separate auto-increment PK field is used, it should at least be as big as the biggest of the FK fields, so it ahould be an INT and surely not a SMALLINT.



Cheers for your input.
I've noted down your valid points, and I'll include the updates to the next Github repo push.

I try the live demo (http://haseydesign.com/flexi-auth/auth_lite/demo) but I am not able to log in as public user (logging in as the two others, admin and moderator, does work however.
Can this be confirmed?

Hey Klausch,
You are indeed correct. Something obviously must have gone awry around launch.
I've updated both, the live demo and the Github repo to fix this glitch. The login details remain the same.


Thanks again for the quick reaction!
I have downloaded the new zipfile from the Github repo (haseydesign-flexi-auth-806f08e.zip), but when recursively comparing the content with the previous version (b639cc8), no differecnes are reported, except for the file dates...
MAybe I am missing something, but can you tell what has been modified between those two releases?

And one more issue, I have developed a first user registration system for our website, I do not use a separate custom user table but have extended the existing user_account table, which should be perfectly legal accoding to the documentation.

When trying to register a new user, trhe following errors are issued:

A PHP Error was encountered
Severity: Notice
Message: Undefined property: stdClass::$tbl_custom_data
Filename: models/flexi_auth_model.php
Line Number: 389

A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: models/flexi_auth_model.php
Line Number: 389

A PHP Error was encountered
Severity: Notice
Message: Undefined variable: row_id
Filename: models/flexi_auth_model.php
Line Number: 420

The errors originate from the fact that in flexi_auth_model.php, the method insert_custom_user_data(...) is called but no variable ['database']['custom'] is defined in the config file.

Already before commiting, the following error was shown. I remember I had seen this error before when running the demo and had commented out line 86, but this was not the solution because the $this->auth->tbl_custom_data is used in the insert_user method.
A PHP Error was encountered
Severity: Notice
Message: Undefined index: custom
Filename: models/flexi_auth_lite_model.php
Line Number: 86
($this->auth->tbl_custom_data = $this->auth->auth_database['custom']Wink

I think a solution might be defining the ['database']['custom'] variable as an empty array, but this is not mentiond in the confi file so I would like to hear your opinion.

Hey again Klausch,
It's good to see you're making some progress with the library.

Regarding the last Git commit, the only difference was a quick update to the demo sql dump, that would fix the incorrect login details for the 'public' user.
You can see the change highlighted @ https://github.com/haseydesign/flexi-aut...03ea9515c2

You would only need to update this if you're using the demo sql data.
In which case if you could also just use the following sql to update your existing database data.
UPDATE `user_accounts`
SET `uacc_password` = '$2a$08$GlxQ00VKlev2t.CpvbTOlepTJljxF2RocJghON37r40mbDl4vJLv2',
    `uacc_salt` = 'CDNFV6dHmn'
WHERE `uacc_id` = 3;


Regarding the error with the custom user data, I think you're using the wrong function for the table you are targeting.

The 'insert_custom_user_data()' and 'update_custom_user_data()' functions are only for updating data within custom user tables that you have added.

If you have just added additional columns to the main user account table, then you need to define the column name and value via the 'user_data' argument in both the 'insert_user()' and 'update_user()' functions.

Function references:

So if for example you had a custom column within the main user account table named 'column_1' and 'column_2, you would update that column with the following code.
$user_id = 101;
$user_data = array('column_1' => 'Column Data #1', 'column_2' => 'Column Data #2');

update_user($user_id, $user_data);

Note: Ensure you have defined these custom columns in the flexi auth config file via the following setting:
$config['database']['user_acc']['custom_columns'] = array('column_1', 'column_2');



Thanks again for the info, you are totally right about the difference in the sql script, my diff tool did not consider files with exactly the same size as different... Sad

THe second issue is more complicated I am afraid.
I never call insert_custom_user_data() directory directly. What I do is calling the library function insert_user(...):
$response = $this->flexi_auth->insert_user($email, $username, $password, $profile_data, 1, $instant_activate);

which in turn delegates the call to the corresponding function in the flexi_auth_model:

The insert_custom_user_data() is called from this model function, in line 217:
$this->insert_custom_user_data($user_id, $custom_data);

And indeed I have configured the custom columns in the configuration file:
// Custom columns can be added to the main user account table to enable library functions to handle additional custom data stored within the table.
$config['database']['user_acc']['custom_columns'] = array(
  ### Example : 'date_modified', 'modified_user_id' etc.
  'first_name', 'last_name', 'company', 'phone', 'usertype_id', 'avatar'

So still struggling with this, I need some more time to figure it out but if you still have some more hints, they are welcome Smile

I may 'possibly' have found the issue that you are having.

Since you say you are not using any custom user data tables, have you by any chance deleted all references to custom users tables in the config file (As you should).
For example, do you have any config setting defined similar to the following:
$config['database']['custom']['YOUR_CUSTOM_TABLE']['table'] = 'custom_table';

Without any reference to a custom table, there was a bug in the library that would throw an error warning.

I have since tweaked the lite model to fix this warning appearing.
You can get this update from the Github repo, or just change line 86 in flexi_auth_lite_model.php
to the following:
$this->auth->tbl_custom_data = (! empty($this->auth->auth_database['custom'])) ? $this->auth->auth_database['custom'] : array();

If this doesn't fix your problem, then can you confirm you have structured your '$profile_data' argument that is being passed to the 'insert_user()' function is similar to as follows:
$profile_data = array(
    'first_name' => 'first name value',
    'last_name' => 'last name value',
    'company' => 'company value',
    'phone' => 'phone value',
    'usertype_id' => 101,
    'avatar' => 'avatar value'


I was exactly thinking in that direction. Indeed I have no references to custom tables in the config file. And I had already commented out line 86 of the flexi_auth_lite_model.php so was close to the solution Smile

I just did run a first test and it appears the problem is solved! Also the extra custom fields are added correctly to the user_account table.
There remains one warning/error message:

A PHP Error was encountered
Severity: Notice
Message: Undefined variable: row_id
Filename: models/flexi_auth_model.php
Line Number: 420

And this confirms my idea that the return value $row_id of the function insert_custom_user_data(...) is meaningless, this function loops over zero or ore custom tables, so each of these tables will have a separate insert id. So return the insert id is not possible and in this case, raises a warning because no custom tables exist.

return $row_id;  (line 420)

But I have set some more steps towards a working system, thanks for you help again and I will keep you posted!

[eluser]Dynamica Technology[/eluser]
Hi I'm a new codeigniter developer and I'm very interested at flexi auth.

I have a problem, in my local webserver, with the demo.

it's no work

I read the installation guide and make step by step.

When I open the local url (http://test.loc) the demo's homepage shows but when I want to go on Demo link I see a 404 error and the relative url is http://test.loc:82/auth_lite/demo

why ? where I wrong.

Please help me


Theme © iAndrew 2016 - Forum software by © MyBB