EllisLab text mark
Advanced Search
1 of 17
1
   
flexi auth - A user authentication library for CodeIgniter
Posted: 19 September 2012 12:14 AM   [ Ignore ]   [ # 11 ]   [ Rating: 0 ]
Joined: 2012-03-08
159 posts

Hey Klausch,

What you need to do to automatically activate user accounts is set the ‘activate’ argument as ‘true’ when inserting the user via the ‘insert_user()’ function.
You can read up on this function at http://haseydesign.com/flexi-auth/user_guide/user_account_set_data#insert_user

By setting the account activation to ‘true’, users will instantly be able to use their account. However, if you were wishing to just by-pass the activation email, and still have an admin review the account, then there is a setting in the config file to suspend all new accounts.

$config['settings']['suspend_new_accounts'true

You can read up on this setting at http://haseydesign.com/flexi-auth/user_guide/user_account_config#behaviour_config_settings

—————————————————————————————-

A little off topic regarding not sending emails from the dev environment.
If the reason you’ve not got this running is the associated hassle setting it up (Setting up Mercury via Xampp was a nightmare for me), may I recommend try installing hmailserver, you can even associate the SMTP with a GMail account just for testing.

Another mail server I saw just yesterday was Mailcatcher, but I haven’t personally tried this yet.

—————————————————————————————-

I’m interested in your comments regarding the database keys.
You’re right that the foreign key constraints should be defined, I’ll add this with my next round of tweaks.
Regarding some of primary keys being redundant, could you elaborate a little more on which fields you are referring to?

 Signature 

flexi-auth | A user authentication library for CodeIgniter.
flexi-cart | An e-commerce shopping cart library for CodeIgniter.

 
Posted: 19 September 2012 12:58 AM   [ Ignore ]   [ # 12 ]   [ Rating: 0 ]
Avatar
Joined: 2009-05-17
1415 posts

What I do for localhost email is just write the contents of the email to a log file, one for each email. It works well because you get to check for php errors.

 Signature 

Brian
Brian’s Web Design - Temecula
Community Auth - CodeIgniter Authentication Application

 
Posted: 19 September 2012 01:13 PM   [ Ignore ]   [ # 13 ]   [ Rating: 0 ]
Joined: 2012-09-13
19 posts

Thank you guys for your quick reactions!
For now I have found a solution for the mail problem: I installed ssmtp on my Ubuntu server machine and configured it to send mail using the SMTP server of my provider.
And this works, though I have no been able to deploy the demo version from my local machine to the server machine. The URL (***.localhost) is hardcoded in all controllers and I just had to change it each time when testing on my local machine or on the test server, which is a different machine on the local network.
Even in the comment is written that is os no good practice and I see really no reason to hard code a URL or directory in all controller classes while the base url is already defined in the config file.

I am struggling with the rest of the code, too. I do not understand the separation between the normal and lite versions of the code, a very basic function as login() is defined in the Flexi_auth library class, so what is the point in defining a _lite superclass which has no login functionality defined so is hardly usable by itself?
Or is the lite version meant to be used only by the controller methods for already logged in users?

To make my confusion worse, when installing the non-demo version, the two model classes (flexi_auth_lite_model and flexi_auth_model) do not define a login() method. So do I need to copy the code from the demo model classes?

SO right now I am utterly confused by this code and the distinction between lite/not-lite as well as between demo/nondemo versions.
I will give it one more day before deciding to go on with it or get back to the original IonAuth.

 
Posted: 19 September 2012 02:32 PM   [ Ignore ]   [ # 14 ]   [ Rating: 0 ]
Joined: 2012-09-19
2 posts

i am getting PHP errors while trying to login while opening auth/index

A PHP Error was encountered
Severity
Notice
Message
Undefined propertystdClass::$session_name
Filename
libraries/Flexi_auth_lite.php
Line Number
172

A PHP Error was encountered
Severity
Notice
Message
Undefined propertystdClass::$session_data
Filename
libraries/Flexi_auth_lite.php
Line Number
172

A PHP Error was encountered
Severity
Notice
Message
Undefined propertystdClass::$tbl_col_user_account
Filename
models/flexi_auth_model.php
Line Number
1940

A PHP Error was encountered
Severity
Notice
Message
Undefined propertystdClass::$tbl_col_user_account
Filename
models/flexi_auth_model.php
Line Number
1941

A PHP Error was encountered
Severity
Notice
Message
Undefined propertystdClass::$auth_security
Filename
models/flexi_auth_model.php
Line Number
1941

A PHP Error was encountered
Severity
Notice
Message
Undefined propertystdClass::$tbl_user_account
Filename
models/flexi_auth_model.php
Line Number
1945 

This makes

$this->auth->tbl_user_account NULL in function ip_login_attempts_exceeded() 

thereby giving database error in the end.

Weird thing is checking value in its constructor gives the right value. I have checked this with a new installation of CI and Flexi

what am i doing wrong?

 
Posted: 19 September 2012 08:19 PM   [ Ignore ]   [ # 15 ]   [ Rating: 0 ]
Joined: 2012-03-08
159 posts

@Klausch

Let me try to clear up some of your confusion.

The split between the ‘lite’ library and the ‘main’ library should be considered a feature, it is not a requirement.
Whenever you include the main library, it extends the lite library meaning functions in both versions are available to you.
If you want to include the main library on every page, that is fine, it will just consume a little more memory on every page load.

The easiest way to look at the purpose of each library version is this:

+ The lite library is used to getting user data, and for checking user credentials - things that you are likely to need to do on every page load - e.g. checking whether a user is logged in and then displaying their name.

+ The main library is the work horse, performing actions like login, registration and forgotten password functionality. You are likely to only need to use these functions when a specific action happens, like a login form being submitted.

An example of the how/why you would use the lite library can be seen at http://haseydesign.com/flexi-auth/auth_lite/lite_library (Login as different demo users to see how different data is returned).

——————————————————————

Regarding you not being able to find the login() method in either model, its in the ‘flexi_auth_model’, but there is no reason for you to change any data within any of the flexi auths model or library files.
The demo models are purely for the examples within the demo site and have no part in how flexi auth works - they are examples of how to use flexi auth functions within a website.

——————————————————————

Regarding the ‘base_url’ being defined in each controller, this is purely for the purposes of the demo so that it is easier for users to quickly get setup and running.
The 3 vars that are set within each controller are defined there so that they are available for creating href link paths within Views.
It is not used in the same was as the ‘base_url’ defined within CI’s config.php file that is used for routing.

 Signature 

flexi-auth | A user authentication library for CodeIgniter.
flexi-cart | An e-commerce shopping cart library for CodeIgniter.

 
Posted: 19 September 2012 08:20 PM   [ Ignore ]   [ # 16 ]   [ Rating: 0 ]
Joined: 2012-03-08
159 posts

@karanits

I would presume there is an incorrect setting somewhere in the flexi_auth config file, but without looking at your setup it hard to know what the specific problem is that’s causing the error.

What I would suggest is that you start a brand new bare installation of CI and flexi auth, then run through the installation guide @ http://haseydesign.com/flexi-auth/user_guide/installation
It is very important that this guide is closely followed, as the slightest omission can cause errors.

Then just follow examples within the demo files on how to setup your controller and a basic view file.
Do not get complicated from the start, just have a simple form within the view file that gets a user to login and see how it goes.

To give you some example data, you may want to use the sql dump and the flexi auth config files from the demo to give you a head start.
Once you get the basics working, then customise the database tables and config file settings to your requirements.

 Signature 

flexi-auth | A user authentication library for CodeIgniter.
flexi-cart | An e-commerce shopping cart library for CodeIgniter.

 
Posted: 20 September 2012 03:16 AM   [ Ignore ]   [ # 17 ]   [ Rating: 0 ]
Joined: 2012-09-19
2 posts

@haseydesign
I found the issue. the errors come when ‘form_validation’ library is auto-loaded in beginning. Is there a specific reason for this error or is it still my installation issue.

PS: this time i did a complete new install.

 
Posted: 20 September 2012 03:25 AM   [ Ignore ]   [ # 18 ]   [ Rating: 0 ]
Joined: 2012-03-08
159 posts

@karanits

That actually sounds like that’s a bug with the library, something that I will try and test out ASAP.
I’ll keep you posted with my testing.

Thanks for reporting this.

 Signature 

flexi-auth | A user authentication library for CodeIgniter.
flexi-cart | An e-commerce shopping cart library for CodeIgniter.

 
Posted: 20 September 2012 08:39 AM   [ Ignore ]   [ # 19 ]   [ Rating: 0 ]
Joined: 2012-09-13
19 posts
haseydesign - 19 September 2012 08:19 PM

@Klausch

Let me try to clear up some of your confusion.

The split between the ‘lite’ library and the ‘main’ library should be considered a feature, it is not a requirement.
Whenever you include the main library, it extends the lite library meaning functions in both versions are available to you.
If you want to include the main library on every page, that is fine, it will just consume a little more memory on every page load.

The easiest way to look at the purpose of each library version is this:

+ The lite library is used to getting user data, and for checking user credentials - things that you are likely to need to do on every page load - e.g. checking whether a user is logged in and then displaying their name.

+ The main library is the work horse, performing actions like login, registration and forgotten password functionality. You are likely to only need to use these functions when a specific action happens, like a login form being submitted.

An example of the how/why you would use the lite library can be seen at http://haseydesign.com/flexi-auth/auth_lite/lite_library (Login as different demo users to see how different data is returned).

——————————————————————

Regarding you not being able to find the login() method in either model, its in the ‘flexi_auth_model’, but there is no reason for you to change any data within any of the flexi auths model or library files.
The demo models are purely for the examples within the demo site and have no part in how flexi auth works - they are examples of how to use flexi auth functions within a website.

——————————————————————

Regarding the ‘base_url’ being defined in each controller, this is purely for the purposes of the demo so that it is easier for users to quickly get setup and running.
The 3 vars that are set within each controller are defined there so that they are available for creating href link paths within Views.
It is not used in the same was as the ‘base_url’ defined within CI’s config.php file that is used for routing.

Hi, thanks again for your reply. I think I am getting things a bit better now.
I made a sketch for myself to clear up some issues, I understand now that the flexi_auth_model class just extends the flexi_auth_model lite class and for the first tests I can just use the subclass version.

Other issue was the demo model classes which I first considered to be a replacement for the core model classes, but now I understand that they are just another layer:
Summarized the layers can be shown as follows:

|---------- DEMO  FILES --------------------|  |---------- CORE FLEXIAUTH LIBRARY FILES ----|
 
views <--- demo controllers --> demo model -> library -->l ibrary model ---> database tables 

Remains the issue of the 3 vars in each controller, I think is is still messy that they should be modified in 5 places or so, and a constant could be better defined for it, but maybe I am missing something yet…
After talking to my project leader we continue evaluating FlexiAuth and will tryo to set up a basic register/login system next weeks. So I will keep you informed…

 
Posted: 21 September 2012 05:47 AM   [ Ignore ]   [ # 20 ]   [ Rating: 0 ]
Joined: 2012-09-13
19 posts

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.

 
Posted: 21 September 2012 09:20 PM   [ Ignore ]   [ # 21 ]   [ Rating: 0 ]
Joined: 2012-03-08
159 posts

@Klausch

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

 Signature 

flexi-auth | A user authentication library for CodeIgniter.
flexi-cart | An e-commerce shopping cart library for CodeIgniter.

 
Posted: 24 September 2012 07:33 AM   [ Ignore ]   [ # 22 ]   [ Rating: 0 ]
Joined: 2012-09-13
19 posts

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?

 
Posted: 24 September 2012 08:21 AM   [ Ignore ]   [ # 23 ]   [ Rating: 0 ]
Joined: 2012-03-08
159 posts

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.

 Signature 

flexi-auth | A user authentication library for CodeIgniter.
flexi-cart | An e-commerce shopping cart library for CodeIgniter.

 
Posted: 26 September 2012 08:12 AM   [ Ignore ]   [ # 24 ]   [ Rating: 0 ]
Joined: 2012-09-13
19 posts

Hi,

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 propertystdClass::$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()
Filenamemodels/flexi_auth_model.php
Line Number
389

A PHP Error was encountered
Severity
Notice
Message
Undefined variablerow_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’];)

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.

 
Posted: 26 September 2012 09:11 AM   [ Ignore ]   [ # 25 ]   [ Rating: 0 ]
Joined: 2012-03-08
159 posts

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-auth/commit/806f08e8854598af2d231bc0c4d37903ea9515c2

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:
http://haseydesign.com/flexi-auth/user_guide/user_account_set_data#insert_user
http://haseydesign.com/flexi-auth/user_guide/user_account_set_data#update_user

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'); 

 

 Signature 

flexi-auth | A user authentication library for CodeIgniter.
flexi-cart | An e-commerce shopping cart library for CodeIgniter.

 
1 of 17
1