tymondesigns / jwt-auth

🔐 JSON Web Token Authentication for Laravel & Lumen
https://jwt-auth.com
MIT License
11.23k stars 1.55k forks source link

JWT 1.0.0-rc.1 with laravel-doctrine 1.4 and laravel 5.5 - User Provider getModel() #1310

Open iamnimnul opened 6 years ago

iamnimnul commented 6 years ago

Hi there.

In my current configuration I am using: "laravel/framework": "5.5.", "laravel-doctrine/orm": "1.4.", "tymon/jwt-auth": "^1.0.0-rc.1"

After installing JWT I spotted an issue. Call to undefined method LaravelDoctrine\\ORM\\Auth\\DoctrineUserProvider::getModel()

Tymon\JWTAuth\JWTGuard in line 77 https://github.com/tymondesigns/jwt-auth/blob/develop/src/JWTGuard.php#L77 says $this->jwt->checkProvider($this->provider->getModel()). This code is assuming that user provider will implement getModel() function like EloquentUserProvider does https://github.com/laravel/framework/blob/5.5/src/Illuminate/Auth/EloquentUserProvider.php#L171, but for example DoctrineUserProvider.php https://github.com/laravel-doctrine/orm/blob/1.4/src/Auth/DoctrineUserProvider.php doesn't have it. User class can be taken from auth.php config I believe?

It's related to https://github.com/tymondesigns/jwt-auth/pull/1167/files made by @cappuc

Please let me know your thoughts. Thanks!

rgwsk65 commented 6 years ago

I'm having the same issue. As you said, replacing the line 77 in JWTGuard.php from $this->jwt->checkProvider($this->provider->getModel()) to $this->jwt->checkProvider(config('auth.providers.users.model')) seems to fix this issue.

iamnimnul commented 6 years ago

It's fixed with laravel-doctrine 1.4.3 released 8 days ago composer update should do the job now ;) Missing getModel() function is added https://github.com/laravel-doctrine/orm/blob/1.4.3/src/Auth/DoctrineUserProvider.php#L140