tymondesigns / jwt-auth

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

Non-static method JWTAuth::attempt() #1151

Open sayber opened 7 years ago

sayber commented 7 years ago

Non-static method Tymon\JWTAuth\JWTAuth::attempt() should not be called statically

use Tymon\JWTAuth\JWTAuth; .... if (!$token = JWTAuth::attempt($credentials)) { return response()->json(['error' => 'invalid_credentials'], 401); }

app.php 'JWTAuth' => Tymon\JWTAuth\Facades\JWTAuth::class,

jonagoldman commented 7 years ago

You need to

use JWTAuth;

instead of

use Tymon\JWTAuth\JWTAuth;

Because you have already added the JWTAuth alias to 'app.php'.

Take a look at the creating tokens examples.

sayber commented 7 years ago

Image of Yaktocat

jonagoldman commented 7 years ago

Oh, are you using 1.0.0-beta or 0.5.11?

sayber commented 7 years ago

0.5.11

sayber commented 7 years ago

This works, then embarrasses the code highlighting

francisrod01 commented 7 years ago

@sayber this is solved?

mahdiasadi1 commented 7 years ago

i have same problem please help

zhongjixiuxing commented 7 years ago

me too for 0.5.*

oliver-com commented 6 years ago

We offten use this

use Tymon\JWTAuth\JWTAuth;

In fact, it use this one

use Tymon\JWTAuth\Facades\JWTAuth;

I have config this in App.php ['aliases'] So, we instead

use Tymon\JWTAuth\JWTAuth;

to

use JWTAuth;
Jason-Nake commented 5 years ago

me too for 1.0.0.* I have config this in APP.php ['aliases'] 'JWTAuth' => Tymon\JWTAuth\Facades\JWTAuth::class, So,i instead use Tymon\JWTAuth\JWTAuth; to use JWTAuth; but,it't not works!why?it tip me the JWTAuth is not defined

Jason-Nake commented 5 years ago

please instead config\jwt..php : 'jwt' => 'Tymon\JWTAuth\Providers\JWT\NamshiAdapter', as 'jwt' => Tymon\JWTAuth\Providers\JWT\Namshi::class , 'auth' => 'Tymon\JWTAuth\Providers\Auth\IlluminateAuthAdapter' as 'auth' => Tymon\JWTAuth\Providers\Auth\Illuminate::class , 'storage' => 'Tymon\JWTAuth\Providers\Storage\IlluminateCacheAdapter' as 'storage' => Tymon\JWTAuth\Providers\Storage\Illuminate::class