Comments (14)
Hi, I have the same problem, I googled a lot, but I didn't find anything useful
ReflectionException in Container.php line 776:
Class App\User does not exist
In file config.php of this library, I have the same namespace than auth.php
laravel auth.php:
'model' => 'Backend\User',
jwt config.php:
'user' => 'Backend\User',
The piece of code that is returning this error is like the example in the docs
class UserController extends Controller
{
public function login()
{
$credentials = Input::only('email', 'password');
if (!$token = JWTAuth::attempt($credentials)) {
return Response::json(['error' => 'invalid_credentials'], 401);
}
return Response::json(compact('token'));
}
Am I missing something in the configuration of JWT?
Thanks
from jwt-auth.
I'm having the same issue and changing the namespace in auth and jwt config makes no difference.
from jwt-auth.
I also have the same problem, i.e I have created a separate namespace for models as App\Models\User
and even though I have changed model name in jwt config.php as below :
'user' => 'App\Models\User'
I am getting below error:
local.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Class '\App\User' not found' in /var/www/html/dsa/backend/vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php:1 26
and doesn't work until I update
laravel auth.php:
'model' => App\Models\User::class
+1 @olso
from jwt-auth.
What code are you running to trigger the exception?
from jwt-auth.
ok, thanks for the extra info. I will try to reproduce this later today
from jwt-auth.
struggling to reproduce this tbh... there's only one place that this is referenced. And it seems likely that this would have been raised by others if it was an issue with the package
Is this still an issue for you ?
from jwt-auth.
It's totally fixable... You have to change the model in Laravel (4.2) auth.php to Namespace\User
Then it will work
from jwt-auth.
Did you get to the end of this? Im getting the same error on Lara 5
from jwt-auth.
.ignore - I just needed to amend config/jwt.php line 67 amended the User path. Sorted.
from jwt-auth.
why have to update laravel auth.php 'model' => App\Models\User
,doesn't laravel use JWT to authenticate?
from jwt-auth.
Hi, I have recently started learning Laravel-5 and i am developing rest web service. To make api secure i am using JWT. I am facing the same issue as stated above.
I have moved the user class from "App\User" to "App\Models\User" and i have added following code in jwt.php
'user' => 'App\Models\User', // code in jwt.php
Inside my Controller Action i have written following code
public function signIn(SignInRequestValidationRules $request)
{
$credentials = $request->only('email', 'password');
try {
if(! $token = JWTAuth::attempt($credentials)) {
return response()->json(['error' => 'invalid_credentials'], 401);
}
} catch (JWTException $e) {
return response()->json(['error' => 'could_not_create_token'], 500);
}
return response()->json(compact('token'));
}
Now whenever i am accessing signIn action using postman i am getting the following exception message.
"Class '\App\User' not found At Line 130 in E:\xampp\htdocs\laravel-rest-service\vendor\laravel\framework\src\Illuminate\Auth\EloquentUserProvider.php"
Kindly provide your valuable inputs.
from jwt-auth.
It looks cache/autoload issue:
composer dump-autoload
php artisan clear-compiled
and then restart your server. Just search the "App\User" in your project to get better idea
from jwt-auth.
@ganeshghalame thanks for giving your valuable time.
I tried the same but the issue still remains, but at end i found the solution. I am providing the link of solution, which can be used by others as well.
Rest the changes needs to be done in Auth.php to replace App\User to App\Models\User and same in Jwt.php. I have also replaces all the Occurence of App\User to App\Models\User Project wide as there is no class App\User in my project anymore.
from jwt-auth.
For anyone that is here looking for solution, I ran into this because I had my class as a string. In config/jwt.php change:
'user' => '\App\Models\User'
to
/*
|--------------------------------------------------------------------------
| User Model namespace
|--------------------------------------------------------------------------
|
| Specify the full namespace to your User model.
| e.g. 'Acme\Entities\User'
|
*/
'user' => \App\Models\User::class,
from jwt-auth.
Related Issues (20)
- Method factory on JWTGuard not found
- setSecret method for custom JWT key is not working HOT 1
- Troubleshooting Issues with Laravel Tests and JWT Authentication HOT 2
- Examples for unmentioned routes (like Email Verification) HOT 1
- Followed the Laravel installation and quick start, getting error: "Tymon\\JWTAuth\\JWTGuard::login(): Argument #1 ($user) must be of type Tymon\\JWTAuth\\Contracts\\JWTSubject
- is possible use sap hana obdc with tymondesigns / jwt-auth ?
- Using a string instead of a file path for the `private` property in `jwt.php`.
- Clarification on Refresh Token Behaviour HOT 5
- attempt() never returns null, but returns blank booleans HOT 1
- Laravel 11 requires an update.
- Laravel 11 Compatibility needs nesbot/carbon ^3.0 HOT 1
- Random @deprecated docs
- Not authenticating api.php routes requests. HOT 3
- Wrong remaining minutes when blacklisting a token HOT 4
- Duplicate query to blacklisted tokens table
- Error when using the auth()->tokenById($id) function. HOT 1
- Redis connection to store blacklisted jwts HOT 1
- How does the jwt invlalidating works ? HOT 1
- TypeError: Carbon\Carbon::rawAddUnit(): Argument #3 ($value) must be of type int|float, string given, HOT 3
- JWTAuth::getJWTProvider()->setSecret( ... dosent work
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jwt-auth.