我正在使用 JWT 在我的 angular - laravel 应用程序中进行身份验证。一切正常,除非需要生成令牌,但出现错误
App\Http\Controllers\JWT
我尝试在 AuthController 中添加以下行:-
use Tymon\JWTAuth\Providers\JWTAuthServiceProvider;
和
use App\Http\Controllers\JWT;
和
use JWT;
但似乎没有任何效果
我的 composer.json :-
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.*",
"tymon/jwt-auth": "0.5.*"
},
AuthController -
$payload = [
'sub' => $user->id,
'iat' => time(),
'exp' => time() + (2 * 7 * 24 * 60 * 60)
];
return JWT::encode($payload, Config::get('app.token_secret'));
public function signup(Request $request){
$user = new User;
$user->name = $request->input('displayName');
$user->email = $request->input('email');
/*$user->password = Hash::make($request->input('password'));*/
$user->password = $request->input('password');
$user->save();
return response()->json(['token' => $this->createToken($user)]);
}