Laravel-mongodb: [v2.2.2][password reminder] other than MongoDate, DatabaseTokenRepository should also take care of array type.

Created on 5 Oct 2015  路  13Comments  路  Source: jenssegers/laravel-mongodb

laravel: 5.1.19
laravel-mongodb: v2.2.2

When I was using Illuminate\Auth\Passwords\PasswordResetServiceProvider, it yields error.

So, I try Jenssegers\Mongodb\Auth\PasswordResetServiceProvider to replace the laravel's, same error.

ErrorException in DatabaseTokenRepository.php line 126: strtotime() expects parameter 1 to be string, array given

["created_at"]=> array(3) { ["date"]=> string(26) "2015-10-05 02:51:23.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" }

In mongodb's DatabaseTokenRepository, I find out it will cast MongoDate only.

it's weird that you did cast array type in the older version, at least in v2.0.5.

Most helpful comment

Laravel 5.2.*
jessenger/mongodb: 3.0.*
PHP 7

For fixing Password Reset case, only what you need to do it's to change Provider for Reset Password

Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,

to

Jenssegers\Mongodb\Auth\PasswordResetServiceProvider::class,

After that created_at will be convert from array to MongoDate and you will not get the Type error: DateTime::__construct() expects parameter 1 to be string, array given error.

@jenssegers Maybe could you add this to the documentation?

Cheers ;)

All 13 comments

LV 5.1, Moloquent: 2.1 - confirmed

Fixed with #663

I still have this issue.

I added the provider to the config.php but it still displays the same error "strtotime() expects parameter ....."

The code never gets inside the "DatabaseTokenRepository.php" that comes on this package, it's always including the "\Illuminate\Auth\Passwords\DatabaseTokenRepository" by default.

Same problem here, doesn't go to the proper class

vendor/laravel/framework/src/Illuminate/Auth/Passwords/DatabaseTokenRepository.php line 126

here are the providers added at the end of the array

Jenssegers\Mongodb\MongodbServiceProvider::class,
Jenssegers\Mongodb\Session\SessionServiceProvider::class,
Jenssegers\Mongodb\Auth\PasswordResetServiceProvider::class

@adriantombu @zeroonnet Which versions of Laravel are you using? There's an issue with 5.2 that has not been resolved yet with Auth.

I'm on the 5.2, so looks like I'll have to wait then ^_^

@adriantombu Temp fix is in #694. I'm hoping to look into this soon if nobody else has by then.

I'm on the 5.2, so looks like I'll have to wait then ^_^

i am having same issue

Laravel Framework version 5.2.14
"jenssegers/mongodb" "version": "v2.3.0",

Laravel 5.2.*
jessenger/mongodb: 3.0.*
PHP 7

For fixing Password Reset case, only what you need to do it's to change Provider for Reset Password

Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,

to

Jenssegers\Mongodb\Auth\PasswordResetServiceProvider::class,

After that created_at will be convert from array to MongoDate and you will not get the Type error: DateTime::__construct() expects parameter 1 to be string, array given error.

@jenssegers Maybe could you add this to the documentation?

Cheers ;)

@darkin1 Hey thanks a lot buddy.... It's working for me now.... :+1:

php: 5.5.9
laravel/framework: 5.2
jenssegers/mongodb : 2.2

Same issue, have tried what @darkin1 stated above, still receiving the exception.

@darkin1 Thanks, you saved my day!!!!
php 5.6
Laravel 5.3
jenseegers/mongodb: ~3.0

In Config/App.php replace Illuminate\Auth\Passwords\PasswordResetServiceProvider on Jenssegers\Mongodb\Auth\PasswordResetServiceProvider
In App/Http/Controllers/Auth/ResetPasswordController.php add use MongoDB\BSON\UTCDateTime;

Timezone: Europe/Moscow
Laravel: 5.7.*
Jenssegers/mongodb: "^3.4"

Was this page helpful?
0 / 5 - 0 ratings

Related issues

imrannazirbhat picture imrannazirbhat  路  3Comments

HassanIbrahim picture HassanIbrahim  路  3Comments

sanjay1688 picture sanjay1688  路  3Comments

lgt picture lgt  路  3Comments

ricardofontanelli picture ricardofontanelli  路  3Comments