laravel-mongodb: Password Reset errors [1 fix/other open]
I just started working with this package, not disappointed so far. However when enabling the PasswordResetServiceProvider I encountered an error when requesting a new password.
In the file Jenssegers/Mongodb/Auth/PasswordBrokerManager.php the method createTokenRepository creates an instance of the DatabaseTokenRepository. However the second argument should be a hash. I copied te code form the original method so the function looks like this:
protected function createTokenRepository(array $config)
{
$key = $this->app['config']['app.key'];
if (Str::startsWith($key, 'base64:')) {
$key = base64_decode(substr($key, 7));
}
$connection = isset($config['connection']) ? $config['connection'] : null;
return new DatabaseTokenRepository(
$this->app['db']->connection($connection),
$this->app['hash'],
$config['table'],
$key,
$config['expire']
);
I tried it and it send the mail as expected.
Also when you have received the password reset email. When you have entered your email and new password a new error occurs.
FatalThrowableError in DatabaseTokenRepository.php line 24: Cannot use object of type MongoDB\BSON\UTCDateTime as array
I think this is because the tokeExpired method expects and $createdAt parameter and receives a $token parameter. I can only assume that those two mean different things.
I used Laravel 5.4.23 when debugging this problem.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 20 (1 by maintainers)
The composer.json after a fresh install has a part that looks exactly like this
Just change it to this
In the same directory as composer.json create a new directory called fixes. If you want to change
Jenssegers/Mongodb/Auth/DatabaseTokenRepository.php
, then create the directories and the file such that you will havefixes/Jenssegers/Mongodb/Auth/DatabaseTokenRepository.php
. Then delete the composer.lock file and install composer again.The namespaces will still remain the same. How the autoload will work it will prioritize the fixes over the package files/classes.
Update: Don’t reïnstall Composer or delete composer.lock. Instead use the rebuild command, this will only rebuild the autoloader.
For the token invalid I found that you also need to change getPayload method from the DatabaseTokenRepository to
Yeah, you don’t have to, but I it is better to keep to the original code in case you miss something.
There is a way, but it is kind of a hacky way. Create a map called fixes and then add in the composer.json file in the psr-4 array a entry called
"Jenssegers\\Mongodb\\": "fixes/Jenssegers/Mongodb/"
. Then take the files you want to replace like theDatabaseTokenRepository.php
and add it tofixed/Jenssegers/Mongodb/Auth/DatabaseTokeRepository.php
. Then you have to reset composer, by deleting composer.lock and install composer again. And it should work.Any update on this issue?
Please Reopen the issue as there is no commit resolve it yet