laravel-mongodb: When I try to reset my password I get this error: FatalThrowableError in Carbon.php line 291: Type error: DateTime::__construct() expects parameter 1 to be string, array given
Hello guys, every time I try to reset my psw I get this error. Using Laravel with MongoDB:
Thanks in advance for the answers
in Carbon.php line 291 at DateTime->__construct(array('date' => '2017-03-28 12:45:33.000000', 'timezone_type' => '3', 'timezone' => 'UTC'), object(DateTimeZone)) in Carbon.php line 291 at Carbon->__construct(array('date' => '2017-03-28 12:45:33.000000', 'timezone_type' => '3', 'timezone' => 'UTC'), null) in Carbon.php line 324 at Carbon::parse(array('date' => '2017-03-28 12:45:33.000000', 'timezone_type' => '3', 'timezone' => 'UTC')) in DatabaseTokenRepository.php line 126 at DatabaseTokenRepository->tokenExpired(array('_id' => object(ObjectID), 'email' => 'ciaoale@gmail.com', 'token' => 'c1b01664ea63f3a7e2a745c29568cb4f595d8af7be19dd20baed8993096375f4', 'created_at' => array('date' => '2017-03-28 12:45:33.000000', 'timezone_type' => '3', 'timezone' => 'UTC'))) in DatabaseTokenRepository.php line 115 at DatabaseTokenRepository->exists(object(User), array('_id' => object(ObjectID), 'email' => 'ciaoale@gmail.com', 'token' => 'c1b01664ea63f3a7e2a745c29568cb4f595d8af7be19dd20baed8993096375f4', 'created_at' => array('date' => '2017-03-28 12:45:33.000000', 'timezone_type' => '3', 'timezone' => 'UTC'))) in PasswordBroker.php line 122 at PasswordBroker->validateReset(array('email' => 'ciaoale@gmail.com', 'password' => 'Alessaalessa656', 'password_confirmation' => 'Alessaalessa656', 'token' => 'c1b01664ea63f3a7e2a745c29568cb4f595d8af7be19dd20baed8993096375f4')) in PasswordBroker.php line 88 at PasswordBroker->reset(array('email' => 'ciaoale@gmail.com', 'password' => 'Alessaalessa656', 'password_confirmation' => 'Alessaalessa656', 'token' => 'c1b01664ea63f3a7e2a745c29568cb4f595d8af7be19dd20baed8993096375f4'), object(Closure)) in ResetsPasswords.php line 46 at ResetPasswordController->reset(object(Request)) at call_user_func_array(array(object(ResetPasswordController), 'reset'), array(object(Request))) in Controller.php line 55 at Controller->callAction('reset', array(object(Request))) in ControllerDispatcher.php line 44 at ControllerDispatcher->dispatch(object(Route), object(ResetPasswordController), 'reset') in Route.php line 189 at Route->runController() in Route.php line 144 at Route->run(object(Request)) in Router.php line 653 at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 53 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in RedirectIfAuthenticated.php line 24 at RedirectIfAuthenticated->handle(object(Request), object(Closure)) in Pipeline.php line 137 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in SubstituteBindings.php line 41 at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 137 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 65 at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 137 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49 at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 137 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64 at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 137 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37 at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 137 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59 at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 137 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104 at Pipeline->then(object(Closure)) in Router.php line 655 at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 629 at Router->dispatchToRoute(object(Request)) in Router.php line 607 at Router->dispatch(object(Request)) in Kernel.php line 268 at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46 at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33 at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104 at Pipeline->then(object(Closure)) in Kernel.php line 150 at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 117 at Kernel->handle(object(Request)) in index.php line 53 at require('/Users/alessandro/Documents/Programmazione/Laravel/ASAP/public/index.php') in server.php line 133
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 4
- Comments: 29 (5 by maintainers)
As mentioned in the documentation, registering the service provider fixed my problem. Added
Jenssegers\Mongodb\Auth\PasswordResetServiceProvider::class,
inconfig/app.php
In Config/App.php replace
Illuminate\Auth\Passwords\PasswordResetServiceProvider
onJenssegers\Mongodb\Auth\PasswordResetServiceProvider
In App/Http/Controllers/Auth/ResetPasswordController.php adduse MongoDB\BSON\UTCDateTime;
Timezone: Europe/Moscow Laravel: 5.7.* Jenssegers/mongodb: “^3.4”
for Laravel 6.0, jenssegers/mongodb 3.6 timezone’ => 'Europe/Paris
In Config/App.php replace Illuminate\Auth\Passwords\PasswordResetServiceProvider on Jenssegers\Mongodb\Auth\PasswordResetServiceProvider
Important: dont forget to clean the password_resets table in your database before testing.
ok, the problem that if someone try to send the rest email while there’s still an reset request on the database it will check with the created_at , for quick resolve just delete the exists request from the database in
Http/Controllers/Auth/ForgotPasswordController.php
use Illuminate\Support\Facades\DB;
public function __construct() { DB::collection('password_resets')->where('email' , request('email'))->delete(); }
Guys i fixed this by adding those classes to the user model.
`<?php
namespace App;
use Illuminate\Notifications\Notifiable; use Illuminate\Contracts\Auth\Authenticatable; use Jenssegers\Mongodb\Eloquent\Model as Eloquent; use Illuminate\Auth\Authenticatable as AuthenticableTrait; use App\Auth\Traits\MagicallyAuthenticatable as MagicallyAuthenticatable; use Illuminate\Auth\Passwords\CanResetPassword; use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
class User extends Eloquent implements Authenticatable, CanResetPasswordContract { use Notifiable, MagicallyAuthenticatable, AuthenticableTrait, CanResetPassword;`
btw, i’m pretty sure that : use Illuminate\Auth\Passwords\CanResetPassword; use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract; solved it and implements it : class User extends Eloquent implements Authenticatable, CanResetPasswordContract
Hope i helped you all.
@Jannnnnn as soon new release will be ready, it fill be fixed. See new about release https://github.com/jenssegers/laravel-mongodb/issues/1926
@Jannnnnn i find problem, see https://github.com/jenssegers/laravel-mongodb/pull/1903
ok i am change carbon on /vendor/nesbot/carbon/src/Carbon/Traits/Creator.php line 80 from parent::__construct($time ?: ‘now’, $timezone); to parent::__construct(strtotime($time) ?: ‘now’, $timezone); and my problem solved
Adding only this solve the issue for me, great!
Getting same problem here also any updates on this?