ivanomatteo/laravel-device-tracking

Have problem with user

Closed this issue · 20 comments

image
i have 2 sections (API, Web) after installation.
then i try to login and it's return with this error above.

Laravel Framework 7.27
PHP 7.3
MySQL 8

Really strange,
I can't understand how getHijackingDetector() can return a string.
Do you have the latest version? Try to reinstall the composer package.

it's a fresh install package, but still has an error
what's a minimum version of laravel to be use this package.

I developed the package on laravel 7.
where \DeviceTracker::detectFindAndUpdate(); is called from?

protected function authenticated(Request $request, $user) in App\Http\Controllers\Auth\LoginController ?

try also to start a tinker session, and call:

\DeviceTracker::getHijackingDetector()
what it returns?
a string? an object?

Now i was update to Laravel 8 but still have same error response.
code \DeviceTracker::getHijackingDetector() was call in controller with facade
after logged in still return as string

More Clue,

  • Added in App\Model\User with use IvanoMatteo\LaravelDeviceTracking\Traits\UseDevices;
  • All setting in config file by default

Try by debug with laravel still return string
Try by change to object have an error on relationship

Can you post here the string returned?

String IvanoMatteo\LaravelDeviceTracking\DeviceHijackingDetectorDefault (length=64)

Ok, it's weird.

If you do:

resolve('IvanoMatteo\LaravelDeviceTracking\DeviceHijackingDetectorDefault');

What is the result?

Still return as string

It should not.
It should be equivalent to \App::make(....)

And should return an instance of that class.

i try run dd(app()->make(\DeviceTracker::getHijackingDetector()));
and it's return IvanoMatteo\LaravelDeviceTracking\DeviceHijackingDetectorDefault {#1722}

Maybe you have installed some package that override resolve() helper?

Try to update to version 0.1.6, I replaced resolve with app::make to avoid similar problems.
It will be avaible on composer in few minutes

now it's another error, i'm sharing a result here
https://flareapp.io/share/pPvlJXw5

Pretty strange too.
It don't seem related to my lib.
Maybe overriding resolve() could have broken something else?

I suggest to put a breakpoint on a resolve() statement and see where it will go.

Try to update with 0.1.7, and put the right user full classname in the config

updated to 0.1.7 and still same issue.
i was check in db it have 1 row in table devices but no data in device_user

when you call \DeviceTracker::getHijackingDetector()
is the user alredy successfull logged in? It should be.

If you get the error on the relation, double check user model's namespace

Alright, this DeviceTracker::getHijackingDetector() has no error
but DeviceTracker::detectFindAndUpdate() have an error

i'm navigate to detectFindAndUpdate function and debug this variable $this->currentDevice there has no relationship with user

@ivanomatteo Sorry for my bad.
After i update from laravel 7 to 8. i forgot to change folder from model to models then i update the config for user model name space, now everything seems to work