public function check(Request $request, TokenAuth $tokenAuth) { if (!$request->get('JWT')) { $responder = new Responder\Responder(); return $responder->respond(function ($response) { $response->fails = true; $response->messages[] = ['auth' => 'No token']; return $response; }); } $response = $tokenAuth->validate($request->get('JWT')); $response->user = \App\User::with('categories')->where('id', '=', $request->get('userId'))->first(); return \Response::json($response); }
public function tokenValidateAndRespond($request, $rules, $call = null) { if (TokenAuth::fails($request)) { $this->response->fails = true; $this->response->messages = ['Auth', 'Please Login.']; return \Response::json($this->response, 400); } else { return $this->validateAndRespond($request, $rules, $call); } }