Error 500 on user.session.post.post_process

Hi guys,

I am trying to modify the session token by adding some new values to it.
I was following this article from @philicious adding-custom-session-data-to-dreamfactory-jwt-token

I’ve created a PHP event script on user.session.post.post_process.
The problem is that when I try to login to the application i get this error: “strpos() expects parameter 1 to be string, array given”.

If I disable the script the login works again. I’ve tried to leave the script blank, to set it to V8 or NodeJs, but the result is the same
It seems that I am not able to activate any event scripts on user.session.post.post_process.

This is the version data:

>     DreamFactory Version: 2.12.0
>     PHP Version: 7.1.16-1+ubuntu16.04.1+deb.sury.org+1
>     PHP Server API: FPM/FastCGI

This is the trace:

["0 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(2, 'strpos() expect...', '/data/rest/vend...', 131, Array)",
"1 /data/rest/vendor/dreamfactory/df-script/src/Components/BaseEngineAdapter.php(131): strpos(Array, '\\n')",
"2 /data/rest/vendor/dreamfactory/df-script/src/Components/ScriptHandler.php(39): DreamFactory\\Core\\Script\\Components\\BaseEngineAdapter->runScript(Array, 'user.session.po...', Array, Array, NULL)",
"3 /data/rest/vendor/dreamfactory/df-script/src/Handlers/Events/ScriptableEventHandler.php(229): DreamFactory\\Core\\Script\\Handlers\\Events\\ScriptableEventHandler->handleScript('user.session.po...', Array, 'php', Array, Array)",
"4 /data/rest/vendor/dreamfactory/df-script/src/Handlers/Events/ScriptableEventHandler.php(74): DreamFactory\\Core\\Script\\Handlers\\Events\\ScriptableEventHandler->handleEventScript(Object(DreamFactory\\Core\\Script\\Models\\EventScript), Array)",
"5 [internal function]: DreamFactory\\Core\\Script\\Handlers\\Events\\ScriptableEventHandler->handleApiEvent(Object(DreamFactory\\Core\\Events\\PostProcessApiEvent))",
"6 /data/rest/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(369): call_user_func_array(Array, Array)",
"7 /data/rest/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(200): Illuminate\\Events\\Dispatcher->Illuminate\\Events\\{closure}('DreamFactory\\\\Co...', Array)",
"8 /data/rest/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(173): Illuminate\\Events\\Dispatcher->dispatch('DreamFactory\\\\Co...', Array, false)",
"9 /data/rest/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(221): Illuminate\\Events\\Dispatcher->fire(Object(DreamFactory\\Core\\Events\\PostProcessApiEvent))",
"10 /data/rest/vendor/dreamfactory/df-core/src/Components/RestHandler.php(366): Illuminate\\Support\\Facades\\Facade::__callStatic('fire', Array)",
"11 /data/rest/vendor/dreamfactory/df-core/src/Components/RestHandler.php(374): DreamFactory\\Core\\Components\\RestHandler->firePostProcessEvent()",
"12 /data/rest/vendor/dreamfactory/df-core/src/Components/RestHandler.php(216): DreamFactory\\Core\\Components\\RestHandler->postProcess()",
"13 /data/rest/vendor/dreamfactory/df-core/src/Components/RestHandler.php(254): DreamFactory\\Core\\Components\\RestHandler->handleRequest(Object(DreamFactory\\Core\\Utility\\ServiceRequest), '')",
"14 /data/rest/vendor/dreamfactory/df-core/src/Components/RestHandler.php(172): DreamFactory\\Core\\Components\\RestHandler->handleResource(Array)",
"15 /data/rest/vendor/dreamfactory/df-core/src/Services/BaseRestService.php(146): DreamFactory\\Core\\Components\\RestHandler->handleRequest(Object(DreamFactory\\Core\\Utility\\ServiceRequest), 'session')",
"16 /data/rest/vendor/dreamfactory/df-core/src/Services/ServiceManager.php(496): DreamFactory\\Core\\Services\\BaseRestService->handleRequest(Object(DreamFactory\\Core\\Utility\\ServiceRequest), 'session')",
"17 /data/rest/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(221): DreamFactory\\Core\\Services\\ServiceManager->handleServiceRequest(Object(DreamFactory\\Core\\Utility\\ServiceRequest), 'user', 'session', false)",
"18 /data/rest/vendor/dreamfactory/df-core/src/Http/Controllers/RestController.php(159): Illuminate\\Support\\Facades\\Facade::__callStatic('handleServiceRe...', Array)",
"19 /data/rest/vendor/dreamfactory/df-core/src/Http/Controllers/RestController.php(118): DreamFactory\\Core\\Http\\Controllers\\RestController->handleServiceRequest(Object(DreamFactory\\Core\\Utility\\ServiceRequest), 'user', 'session')",
"20 [internal function]: DreamFactory\\Core\\Http\\Controllers\\RestController->handleVersionedService('v2', 'user', 'session')",
"21 /data/rest/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)",
"22 /data/rest/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction('handleVersioned...', Array)",
"23 /data/rest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(212): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(DreamFactory\\Core\\Http\\Controllers\\RestController), 'handleVersioned...')",
"24 /data/rest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(169): Illuminate\\Routing\\Route->runController()",
"25 /data/rest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(658): Illuminate\\Routing\\Route->run()",
"26 /data/rest/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
"27 /data/rest/vendor/dreamfactory/df-core/src/Http/Middleware/AccessCheck.php(62): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
"28 /data/rest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): DreamFactory\\Core\\Http\\Middleware\\AccessCheck->handle(Object(Illuminate\\Http\\Request), Object(Closure))",
"29 /data/rest/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))",
"30 /data/rest/vendor/dreamfactory/df-core/src/Http/Middleware/AuthCheck.php(232): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
"31 /data/rest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): DreamFactory\\Core\\Http\\Middleware\\AuthCheck->handle(Object(Illuminate\\Http\\Request), Object(Closure))",
"32 /data/rest/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))",
"33 /data/rest/vendor/dreamfactory/df-core/src/Http/Middleware/VerbOverrides.php(42): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
"34 /data/rest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): DreamFactory\\Core\\Http\\Middleware\\VerbOverrides->handle(Object(Illuminate\\Http\\Request), Object(Closure))",
"35 /data/rest/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))",
"36 /data/rest/vendor/barryvdh/laravel-cors/src/HandleCors.php(37): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
"37 /data/rest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Barryvdh\\Cors\\HandleCors->handle(Object(Illuminate\\Http\\Request), Object(Closure))",
"38 /data/rest/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))",
"39 /data/rest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
"40 /data/rest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(660): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))",
"41 /data/rest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(635): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))",
"42 /data/rest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(601): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))",
"43 /data/rest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(590): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))",
"44 /data/rest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))",
"45 /data/rest/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))",
"46 /data/rest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
"47 /data/rest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))",
"48 /data/rest/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))",
"49 /data/rest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
"50 /data/rest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure))",
"51 /data/rest/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))",
"52 /data/rest/vendor/barryvdh/laravel-cors/src/HandlePreflight.php(34): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
"53 /data/rest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Barryvdh\\Cors\\HandlePreflight->handle(Object(Illuminate\\Http\\Request), Object(Closure))",
"54 /data/rest/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))",
"55 /data/rest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
"56 /data/rest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))",
"57 /data/rest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))",
"58 /data/rest/public/index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))",
"59 {main}"]

Any suggestions are most welcome.
Thanks
Gabriel