With SimpleAuth package, Im working on login function. By default, user table is supposed to have a column "username". But my system has a user table with "login_id" instead of "username".
Fuel\Core\Database_Exception [ 1054 ]:
Unknown column 'username' in 'where clause'
[ SELECT * FROM `m_user` WHERE (`username` = 'admin' OR `email` = 'admin')
AND `password` = 'mIIMXQgANGZ21XHRTpI2Krpla9yx3UwEw0PCNfjAN4I=' ]
I cannot figure out how it handles custom field name. I tried configuration on APPPATH/config/simpleauth.php with "'username_post_key' => 'login_id'," which did not work..
Thanks in advance.
### APPPATH/config/auth.php ###
return array(
'driver' => 'SimpleAuth',
'verify_multiple_logins' => false,
'salt' => 'techtech',
'iterations' => 10000,
);
### APPPATH/config/simpleauth.php ###
<?php
return array(
'db_connection' => null,
'table_name' => 'm_user',
'table_columns' => array('*'),
'guest_login' => true,
'multiple_logins' => false,
'remember_me' => array(
'enabled' => false,
'cookie_name' => 'rmcookie',
'expiration' => 86400 * 31,
),
'groups' => array(
),
'roles' => array(
),
'login_hash_salt' => 'tech_login',
'username_post_key' => 'login_id',
'password_post_key' => 'password',
);
### user table ###
+----------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+------------------+------+-----+---------+----------------+
| id | int(11) unsigned | NO | PRI | NULL | auto_increment |
| login_id | varchar(100) | NO | | NULL | |
| first_name | varchar(20) | NO | | NULL | |
| last_name | varchar(20) | NO | | NULL | |
| password | varchar(255) | NO | | NULL | |
| last_login_at | timestamp | YES | | NULL | |
| created_at | timestamp | YES | | NULL | |
| updated_at | timestamp | YES | | NULL | |
| deleted_at | timestamp | YES | | NULL | |
+----------------+------------------+------+-----+---------+----------------+
You can't configure it, because username_post_key
is for POST field name, not for table column name. There is no configuration for table column name.
You must customize SimpleAuth, or create your own driver.