delight-im / PHP-Foundation

Writing modern PHP applications efficiently
MIT License
29 stars 7 forks source link

Reset Password TooManyRequestsException #34

Closed daebak74 closed 4 years ago

daebak74 commented 4 years ago

I don't understand why in reset password always receive this error, so after so many test I tried a simple test.

route:

$app->get('/'. EZ_ADMIN_URL .'/password', ['\App\Controllers\Backend\Core\Account', 'getPassword']);

controller:

<?php
    namespace App\Controllers\Backend\Core;
    use Delight\Foundation\App;
    class Account {
        public static function getPassword(App $app) {
            $app->auth()->forgotPassword('email@email.com', function ($selector, $token) {
                echo 'Send ' . $selector . ' and ' . $token . ' to the user (e.g. via email)';
            });
        }
    }

result:

Delight\Auth\TooManyRequestsException:  in file Z:\wamp\www\pf\vendor\delight-im\auth\src\Auth.php on line 1011
Stack trace:
  1. Delight\Auth\TooManyRequestsException->() Z:\wamp\www\pf\vendor\delight-im\auth\src\Auth.php:1011
  2. Delight\Auth\Auth->forgotPassword() Z:\wamp\www\pf\app\Controllers\Backend\Core\Account.php:392
  3. App\Controllers\Backend\Core\Account->getPassword() Z:\wamp\www\pf\vendor\delight-im\router\src\Router.php:260
  4. Delight\Router\Router->addRoute() Z:\wamp\www\pf\vendor\delight-im\router\src\Router.php:63
  5. Delight\Router\Router->get() Z:\wamp\www\pf\vendor\delight-im\foundation-core\src\App.php:750
  6. Delight\Foundation\App->get() Z:\wamp\www\pf\app\routes\backend.php:27
  7. require() Z:\wamp\www\pf\app\index.php:9
  8. require() Z:\wamp\www\pf\index.php:128

The only change that I make is to convert MyISAM in InnoDB for use the Foreign Key with the extra users field table.

Thanks.

daebak74 commented 4 years ago

Please forgot I truncate the table users_resets and not seems work.

I don't know if is right. I mean if an user make a reset request and for any reason failed and make again a reset request will be generated this exception or I am in wrong ?

If yes please close it.

Thanks

ocram commented 4 years ago

Sorry, we can’t support any non-standard (custom) database configurations.

If the same problem occurs with the default database schema, let’s discuss this.

Anyway, from here, which might help you:

During development, you may want to disable the request limiting or throttling performed by this library. To do so, pass false to the constructor as the fourth argument, which is named $throttling. The feature is enabled by default.

Apart from that, you may have to clear the users_throttling table as well. That rarely makes sense in production, though, and thus only during development. But during development, the option above may be the better solution.

daebak74 commented 4 years ago

Thanks fixed the problem!

I posted because in different post I read that your coding for this library is with mind to support InnoDB and that maybe in future to migrate to it.

By the way now I know so I will avoid posting issues that can be caused by the type of database.

ocram commented 4 years ago

The library tries to support multiple database systems, i.e. MySQL/MariaDB, PostgreSQL and SQLite. And in the future, the MySQL engine might be changed from MyISAM to InnoDB. But not yet. Until then, no support is possible.