JWTAuth返回的令牌与预期不符,console.log未定义

时间:2015-12-08 11:52:17

标签: laravel laravel-5.1 jwt satellizer json-web-token

令牌返回我的JWTAuth并且未定义Laravel。本地存储显示

satellizer_token: [object Object]

AuthController

protected function createToken($user)
{
    $customClaims = [
        'sub' => $user->id,
        'iat' => time(),
        'exp' => time() + (2 * 7 * 24 * 60 * 60)
    ];

    $payload = app('tymon.jwt.payload.factory')->make($customClaims);
    return JWTAuth::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)]);
}

0 个答案:

没有答案