User Account Configuration
User Account Index |
Get User Account Data |
Set User Account Data
Help with the Table Configuration
Show / Hide Help
Config Name: The name that flexi auth internally references the config setting by.
Default: The default value set within the config file.
Data Type: The data type that is expected by the config setting.
- bool : Requires a boolean value of 'TRUE' or 'FALSE'.
- string : Requires a textual value.
- int : Requires a numeric value. It does not matter whether the value is an integer, float, decimal etc.
- array : Requires an array.
- datetime : Requires a datetime value. Typically either a MySQL DATETIME (2000-12-31 12:00:00) or UNIX timestamp (1234567890)
Config File Location
The config file is located in CodeIgniters 'config' folder and is named 'flexi_auth.php'.
Schema Diagram : User Account Table
A database table schema diagram, showing how the primary user account table is the core table within the flexi auth library, linking to each of the other tables used by the library.
Note: Table and columns names are defined using their config names referenced within the config file. The names within brackets are the default demo names.
Primary User Account Table
The primary user account table contains all of the columns required for different functions within the flexi auth library.
Table and Column Setup
Help
Config Name |
Default |
Data Type |
Description |
table |
user_accounts |
- |
The tables name. |
join |
user_accounts.uacc_id |
- |
The tables foreign key used to join with foreign keys of other tables. |
id |
uacc_id |
int |
The tables primary key. |
group_id |
uacc_group_fk |
int |
The foreign key used to join with the user group table. |
email |
uacc_email |
string |
The users email address. |
username |
uacc_username |
string |
The users login username. |
password |
uacc_password |
string |
The users password. |
ip_address |
uacc_ip_address |
string |
The ip address of the last visit from the user. |
salt |
uacc_salt |
string |
A database salt unique to each user that is used when salting passwords. |
activation_token |
uacc_activation_token |
string |
The account activation token assigned to a user upon registration. |
forgot_password_token |
uacc_forgotten_password_token |
string |
The reset a forgotten password token assigned to a user upon requesting to reset their 'forgotten' password. |
forgot_password_expire |
uacc_forgotten_password_expire |
datetime |
The date that the forgotten password token expires by. |
update_email_token |
uacc_update_email_token |
string |
The update email token assigned to a user upon updating their email address. The token verifies whether the email account is registered to the user. |
update_email |
uacc_update_email |
string |
The email address that is to be updated to the user upon verification. |
active |
uacc_active |
int |
Defines whether the users account has been activated. |
suspend |
uacc_suspend |
int |
Defined whether the users account has been suspended/banned, meaning the user can no longer login. |
failed_logins |
uacc_fail_login_attempts |
int |
The number of failed login attempts that have been made to a users account since their last successful login. |
failed_login_ip |
uacc_fail_login_ip_address |
string |
The ip address of the user that made the last failed login attempt to a users account. |
failed_login_ban_date |
uacc_date_fail_login_ban |
datetime |
If a users account has too many failed logins, its can be banned from being logged into until the defined date. |
last_login_date |
uacc_date_last_login |
datetime |
The last successful login date into a users account. |
date_added |
uacc_date_added |
datetime |
The date the users account was created. |
custom_columns |
- |
array |
Custom columns can be added to the main user account table to enable library functions to handle additional custom data stored within the table.
The custom columns names are defined via an array.
|
Example
$config['database']['user_acc']['table'] = 'user_accounts';
$config['database']['user_acc']['join'] = 'user_accounts.uacc_id';
$config['database']['user_acc']['columns']['id'] = 'uacc_id';
$config['database']['user_acc']['custom_columns'] = array('date_modified', 'modified_user_id');
Custom User Tables
Additional custom tables that are directly related to the user account table can be included in flexi auth CRUD functions by setting their database structure via the the $config['database']['custom'] array.
Typically, such examples of a custom table you may wish to link to the user account table would be a user profile table listing the users name and contact details etc.
Table and Column Setup
Help
Config Name |
Default Name |
Data Type |
Description |
table |
* Custom * |
- |
The tables name. |
primary_key |
* Custom * |
- |
The tables primary key. |
foreign_key |
* Custom * |
- |
The tables foreign key, intended to join the table with the primary key of the primary user account table. |
join |
* Custom * |
- |
The full length table name and foreign key column used to join the table, example 'custom_table_name.foreign_key_name'. |
custom_columns |
* Custom * |
array |
An array of all the other column names within the table. |
Notes
You are not required to include any custom tables if not needed.
You are not limited to the number of different custom tables you can define.
All custom column names in ALL custom tables should be uniquely named. Otherwise, if the update_custom_user_data() is used, it could match the wrong columns when trying to match a primary key column and array data.
Example
$config['database']['custom']['user_address']['table'] = 'user_address';
$config['database']['custom']['user_address']['primary_key'] = 'user_address_id';
$config['database']['custom']['user_address']['foreign_key'] = 'user_account_fk';
$config['database']['custom']['user_address']['join'] = 'user_address.user_account_fk';
$config['database']['custom']['user_address']['custom_columns'] = array(
'user_street','user_city','user_county','user_post_code','user_country'
);
User Account Database Config Settings
Define user account database settings.
Table and Column Setup
Help
Config Name |
Data Type |
Default |
Description |
primary_identity_col |
string |
uacc_email |
Set the column to be used to primarily identify users within the user account table.
Note: Only the 'email' or 'username' columns can be used.
|
identity_cols |
array |
array('uacc_email', 'uacc_username') |
Set whether the users email address, username or both are to be used to identify users from data submitted via a login form.
This MUST include the 'primary_identity_col' column (Default 'uacc_email').
If both the email address and username are used, then users will be able to login by submitting either value.
Note: Only the 'email' and/or 'username' columns can be used.
|
search_user_cols |
array |
array('uacc_email', 'uacc_username') |
Set the table columns that are looked-up by the libraries search_users() function to match users against submitted search query terms.
By default, the config file is defined to only lookup the 'email' and 'username' columns. However, if using custom user tables capturing user profile data etc, those columns can be added to this config setting.
|
date_time |
PHP Date Function |
date('Y-m-d H:i:s') |
Set a native PHP function to format the date and time correctly to be stored within the user tables.
Typically this will either be either DATETIME or TIMESTAMP
MySQL DATETIME = date('Y-m-d H:i:s');
Unix TIMESTAMP = time();
Note: Ensure you consistently use the same data type in all defined flexi auth tables for date and time data.
|
Example
$config['database']['settings']['primary_identity_col'] = 'uacc_email';
$config['database']['settings']['identity_cols'] = array('uacc_email', 'uacc_username');
$config['database']['settings']['search_user_cols'] = array('uacc_email', 'upro_first_name', 'upro_last_name');
$config['database']['settings']['date_time'] = date('Y-m-d H:i:s');
User Account Behaviour Config Settings
Define user account behaviour settings used when handling data related to the primary user account table.
Table and Column Setup
Help
Config Name |
Data Type |
Default |
Description |
auto_increment_username |
bool |
false |
Set whether an incremented number is added to the end of an unavailable username.
Example: If username 'flexi' is already in use, the next user to use 'flexi' as their username will be automatically updated to 'flexi1'.
Note: This only applies if the username is not set as the primary identity column via the setting 'primary_identity_col'.
|
suspend_new_accounts |
bool |
false |
Set whether accounts are suspended by default on registration / inserting user.
This option allows admins to verify account details before enabling users.
|
account_activation_time_limit |
int |
0 |
Set a time limit to grant users instant login access, once expired, they are locked out until they activate their account via an activation email sent to them.
|
Example
$config['settings']['auto_increment_username'] = FALSE;
$config['settings']['suspend_new_accounts'] = FALSE;
$config['settings']['account_activation_time_limit'] = 60; // 60 minutes