ingeniasoftware / luthier-ci

Improved routing, middleware support, authentication tools and more for CodeIgniter 3 framework
https://luthier.ingenia.me/ci/en/
MIT License
151 stars 39 forks source link

I think I got a bug #30

Closed Ihabafia closed 6 years ago

Ihabafia commented 6 years ago

Dear Anderson,

I think I catch a bug, it's in the Controller.com.

It's basically where you check how many times the user requested a password reset. Here is the code:

$requestCount = $this->db->where('email', $this->input->post('email'))
        ->where('created_at >=', date('Y-m-d H:i:s'))
        ->where('created_at <=', date('Y-m-d H:i:s', time() + (60 * 60 * 2))) // 2 hours
        ->count_all_results(config_item('simpleauth_password_resets_table'));

Here here is my suggestion, that makes it works:

$requestCount = $this->db->where('email', $this->input->post('email'))
        ->where('created_at <=', date('Y-m-d H:i:s'))
        ->where('created_at >=', date('Y-m-d H:i:s', time() - (60 * 60 * 2))) // 2 hours
        ->count_all_results(config_item('simpleauth_password_resets_table'));

The >= and <= are reversed, which at the moment it's checking how much time between now and the next 2 hours, while it's supposed to check how many times between now and the last 2 hours.

Thank you,