|
|
|
|
@ -10,6 +10,7 @@ use Illuminate\Support\Facades\Auth;
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
use Illuminate\Support\Facades\Notification;
|
|
|
|
|
use PHPUnit\Exception;
|
|
|
|
|
use Tymon\JWTAuth\Facades\JWTAuth;
|
|
|
|
|
|
|
|
|
|
class AuthController extends Controller
|
|
|
|
|
@ -240,9 +241,9 @@ class AuthController extends Controller
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @OA\Post(
|
|
|
|
|
* path="/manager/refresh",
|
|
|
|
|
* summary="V2-刷新token",
|
|
|
|
|
* @OA\Get(
|
|
|
|
|
* path="/manager/check-token",
|
|
|
|
|
* summary="V2-判断token是否有效",
|
|
|
|
|
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
|
|
|
|
|
* description="",
|
|
|
|
|
* @OA\Response(
|
|
|
|
|
@ -252,6 +253,20 @@ class AuthController extends Controller
|
|
|
|
|
* )
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public function checkToken()
|
|
|
|
|
{
|
|
|
|
|
$id = $this->guard()->id();
|
|
|
|
|
if ($id) {
|
|
|
|
|
return response()->json([
|
|
|
|
|
'token_available' => true
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
return response()->json([
|
|
|
|
|
'errorcode' => '401',
|
|
|
|
|
'errormsg' => "Token已失效"
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Refresh a token.
|
|
|
|
|
*
|
|
|
|
|
@ -260,9 +275,17 @@ class AuthController extends Controller
|
|
|
|
|
|
|
|
|
|
public function refresh()
|
|
|
|
|
{
|
|
|
|
|
$token = JWTAuth::getToken();
|
|
|
|
|
dd($token);
|
|
|
|
|
return $this->respondWithToken($this->guard()->refresh());
|
|
|
|
|
//todo
|
|
|
|
|
if (request()->token) {
|
|
|
|
|
try {
|
|
|
|
|
$new_token = $this->guard()->refresh();
|
|
|
|
|
return $this->respondWithToken($new_token);
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
abort("401");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
abort("401");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|