Closed tikky closed 9 years ago
Hi,
just take a look in the docs:
- 'track_login_attempts' - Track the number of failed login attempts for each user or ip. DEFAULT is 'false'.
I think you have to set this feature to true, so it will work correctly.
http://benedmunds.com/ion_auth/
Best Regards,
Patrick
2014-12-02 10:12 GMT+01:00 tikky notifications@github.com:
Hello,
I am using your library in my private project and I am really happy, works ok. However my "login_attempts" table in database is still empty.
Of course in settings folder name is correct, and settings are set to: _$config['tables']['login_attempts'] = 'loginattempts'; and also: _$config['track_loginattempts'] = TRUE; _$config['track_login_ipaddress'] = TRUE;
Any idea what I can do/check to log users login attemps to my database?
— Reply to this email directly or view it on GitHub https://github.com/benedmunds/CodeIgniter-Ion-Auth/issues/678.
Hey
sry, just see that you have set the setting.
2014-12-02 10:24 GMT+01:00 Patrick Simon pas.freelance@googlemail.com:
Hi,
just take a look in the docs:
- 'track_login_attempts' - Track the number of failed login attempts for each user or ip. DEFAULT is 'false'.
I think you have to set this feature to true, so it will work correctly.
http://benedmunds.com/ion_auth/
Best Regards,
Patrick
2014-12-02 10:12 GMT+01:00 tikky notifications@github.com:
Hello,
I am using your library in my private project and I am really happy, works ok. However my "login_attempts" table in database is still empty.
Of course in settings folder name is correct, and settings are set to: _$config['tables']['login_attempts'] = 'loginattempts'; and also: _$config['track_loginattempts'] = TRUE; _$config['track_login_ipaddress'] = TRUE;
Any idea what I can do/check to log users login attemps to my database?
— Reply to this email directly or view it on GitHub https://github.com/benedmunds/CodeIgniter-Ion-Auth/issues/678.
Please take a look at my original post, like I wrote earlier this option is set to TRUE. Any other idea?
Add debug code to the increase_login_attempts() method in the model to see what the login_attempts config var is being evaluated as here:
https://github.com/benedmunds/CodeIgniter-Ion-Auth/blob/2/models/ion_auth_model.php#L1127
I've saved the result of $ip_address (lin 1127) and it shows me my real local ip address, which is 192.168.6.100. However it was not stored in db.
What else I can check?
Sorry for interrupting but is that IP the same as your server's IP?
My server (local Synology NAS) is 192.168.6.11 and my computer is 192.168.6.100
did you try to do an "echo $_SERVER['REMOTE_ADDR'];". If it shows ::1 then the problem is that your ip is shown in IPv6. See this http://stackoverflow.com/questions/2939311/remote-addr-not-returning-ipv4-address
<? echo $_SERVER['REMOTE_ADDR']; ?>
The above test gave me my proper IP address 192.168.6.100.
dump these values and see what you get:
var_dump($this->tables['login_attempts']); var_dump(array('ip_address' => $ip_address, 'login' => $identity, 'time' => time()));
also post the schema for your login attempts table.
Any updates? Closing until more information is given.
Hi,
Sorry for a long time without answer.
Where do I need to put this code: var_dump($this->tables['login_attempts']); var_dump(array('ip_address' => $ip_address, 'login' => $identity, 'time' => time()));
login_attemps table is also comletly empty, however apart of this two empty tables login system works fine.
In the increase_login_attempts method in the ion auth model
@benedmunds nice person..haha... give lots of helpers for who use this lib.. really cool @tikky ion_auth is just a lib for ci, so just test and follow the code,debug and find the problem.be patient and good luck.
This is what I get: string(14) "login_attempts" array(3) { ["ip_address"]=> string(11) "192.168.6.2" ["login"]=> string(5) "tikky" ["time"]=> int(1418329211) }
what about the 'var_dump($this->tables['login_attempts']);'
What database are you using? Postgres, mysql, sqlserver?
@singleseeker: string(14) "login_attempts"
@benedmunds: MariaDB/MySQL
check your table.
desc login_attempts
mysql> desc login_attempts;
+------------+-----------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+-----------------------+------+-----+---------+----------------+
| id | mediumint(8) unsigned | NO | PRI | NULL | auto_increment |
| ip_address | varbinary(16) | NO | | NULL | |
| login | varchar(100) | NO | | NULL | |
| time | int(11) unsigned | YES | | NULL | |
+------------+-----------------------+------+-----+---------+----------------+
4 rows in set (0.01 sec)
open your php debug in your ci project. change the root folder index.php,also change the increase_login_attempts function like this. see what is going on..
ion_auth_model.php
public function increase_login_attempts($identity) {
if ($this->config->item('track_login_attempts', 'ion_auth')) {
$ip_address = $this->_prepare_ip($this->input->ip_address());
var_dump($this->tables['login_attempts'], array('ip_address' => $ip_address, 'login' => $identity, 'time' => time()));
$this->db->insert($this->tables['login_attempts'], array('ip_address' => $ip_address, 'login' => $identity, 'time' => time()));
log_message('error',$this->db->last_query());
return TRUE;
}
return FALSE;
}
index.php
define('ENVIRONMENT', 'development');
if (defined('ENVIRONMENT'))
{
switch (ENVIRONMENT)
{
case 'development':
error_reporting(E_ALL);
// Display errors in output
ini_set('display_errors', 1);
break;
case 'testing':
case 'production':
error_reporting(0);
// Don't display errors (they can still be logged)
ini_set('display_errors', 0);
break;
default:
exit('The application environment is not set correctly.');
}
}
also you could test this sql script in your sql console see if it works!
INSERT INTO `login_attempts` (`ip_address`, `login`, `time`) VALUES ('127.0.0.1', '671826@qq.com', 1418331061)
@singleseeker That was fine, added correctly. Now I can see this one row in login_attemps table
change the increase_login_attempts function for debug
public function increase_login_attempts($identity) {
if ($this->config->item('track_login_attempts', 'ion_auth')) {
$ip_address = $this->_prepare_ip($this->input->ip_address());
$this->db->insert($this->tables['login_attempts'], array('ip_address' => $ip_address, 'login' => $identity, 'time' => time()));
echo $this->db->last_query();
exit;
return $this->db->insert($this->tables['login_attempts'], array('ip_address' => $ip_address, 'login' => $identity, 'time' => time()));
}
return FALSE;
}
I could not even say a word but weird...
let me know the output when you change the increase_login_attempts function..
ok, have changed the index.php and increase_loing_attemps in models. In DB still no changes in 'login_attempts' tables.
Sorry if my question is lame (I am not a programmer), buy how can I debug project? I am using just notepad++ as a editor for development process.
U know what the increase_login_attempts just detect the user who is not exists.. when u use the user who is exists with the right password. it will not insert a record.
Could u know what I am talking about ?
yes, I know
now, when I've tried to login with different username (which is not exists) data was added to the DB.
However the docs says: 'track_login_attempts' - Track the number of failed login attempts for each user or ip. DEFAULT is 'false'.
So "each users" means only users who do not exists, or even the user with proper username but wrong password?
of course...
track_login_attempts just log people who can not login this project.. include the user who is not exists or user exists but with the wrong password..
Hope now u get your answer and everything goes well.
@singleseeker
Yes, thank you for your help, comments and time
@tikky it is fine
have a nice day.
Hello,
I am using your library in my private project and I am really happy, works ok. However my "login_attempts" table in database is still empty.
Of course in settings folder name is correct, and settings are set to: $config['tables']['login_attempts'] = 'login_attempts'; and also: $config['track_login_attempts'] = TRUE; $config['track_login_ip_address'] = TRUE;
Any idea what I can do/check to log users login attemps to my database?