public function inValidateByIdToken($id) { $tempStorage = app('\\App\\Http\\Controllers\\TEMPStorage\\UserTempStorage'); $tempStorage->forget('id_company', $id); //set model login $this->model->find($id)->update(['login' => 0]); return API::response()->array(['status' => 'success'])->statusCode(200); }
/** * Delete User. * * @SWG\Delete( * path="/users/profile/{user_id}", * tags={"Users"}, * summary="Delete User", * @SWG\Response(response="200", description="Success", * @SWG\Schema( * title="data", * type="object", * @SWG\Property(property="status", type="string", default="Record successfully deleted.", description="Status message from server"), * @SWG\Property(property="user", ref="#/definitions/User"), * ) * ), * @SWG\Response(response="500", description="Could not delete data", * @SWG\Schema( * title="data", * type="object", * @SWG\Property(property="error", type="string", default="could_not_delete_data"), * ) * ), * @SWG\Parameter( * name="user_id", * in="path", * description="USER_ID to delete", * required=true, * type="integer", * default=8 * ) * ) * * @param Request $request * * @return mixed * * @author Donna Borja <*****@*****.**> */ public function destroy(Request $request) { // check if user exists $user = $this->user->whereId($request->user_id)->first(); if (!$user) { return API::response()->array(['status' => USER_DOES_NOT_EXIST])->statusCode(500); } // update users table try { $this->user->whereId($request->user_id)->delete(); } catch (Exception $e) { return API::response()->array(['status' => USER_DELETE_FAIL])->statusCode(500); } return API::response()->array(['status' => USER_DELETE_SUCCESS, 'user' => $user])->statusCode(200); }
public function validateToken() { // Our routes file should have already authenticated this token, so we just return success here return API::response()->array(['status' => 'success'])->statusCode(200); }
/** * Logout currently authenticated user. * * @SWG\Get( * path="/logout", * tags={"Authentication"}, * summary="Logout currently authenticated user.", * @SWG\Response(response="200", description="Signed out", * @SWG\Schema( * title="data", * type="object", * @SWG\Property(property="message", type="string", default="signed_out"), * @SWG\Property(property="status_code", type="integer", default=200), * ) * ), * @SWG\Response(response="400", description="Token not provided", * @SWG\Schema( * title="data", * type="object", * @SWG\Property(property="message", type="string", default="Token not provided"), * @SWG\Property(property="status_code", type="integer", default=400), * @SWG\Property(property="debug", type="object"), * ) * ), * @SWG\Response(response="417", description="Cannot sign out", * @SWG\Schema( * title="data", * type="object", * @SWG\Property(property="message", type="string", default="cannot_sign_out"), * @SWG\Property(property="status_code", type="integer", default=417), * ) * ), * @SWG\Response(response="500", description="Could not create token", * @SWG\Schema( * title="data", * type="object", * @SWG\Property(property="message", type="string", default="could_not_create_token"), * @SWG\Property(property="status_code", type="integer", default=500), * ) * ), * @SWG\Parameter( * name="Authorization", * in="header", * description="JWT Token", * required=true, * type="string", * default="Bearer ", * @SWG\Items(type="string") * ), * ) * * @return \Illuminate\Http\JsonResponse * * @author Bertrand Kintanar <*****@*****.**> */ public function logout() { $response = []; try { if (JWTAuth::parseToken()->invalidate()) { $response['message'] = 'signed_out'; $response['status_code'] = 200; } else { $response['message'] = 'cannot_sign_out'; $response['status_code'] = 417; } } catch (JWTException $e) { $response['message'] = $e->getMessage(); $response['status_code'] = 500; } return API::response()->array(['status' => $response['message'], 'status_code' => $response['status_code']])->statusCode($response['status_code']); }
public function apiResponse($status_code, $data) { $data['status_code'] = $status_code; return API::response()->array($data)->statusCode($status_code); }
|-------------------------------------------------------------------------- | Application Error Handler |-------------------------------------------------------------------------- | | Here you may handle any errors that occur in your application, including | logging them or displaying custom views for specific errors. You may | even register several error handlers to handle different types of | exceptions. If nothing is returned, the default error view is | shown, which includes a detailed stack trace during debug. | */ App::error(function (Exception $exception, $code) { Log::error($exception); }); API::error(function (\Illuminate\Database\Eloquent\ModelNotFoundException $exception) { return Response::make(['error' => $exception->getMessage()], 404); }); App::missing(function ($exception) { if (Request::is('dashboard*') or Request::is('api*')) { return Response::view('errors.404', ['pageTitle' => trans('cachet.dashboard.not_found_title')], 404); } return Redirect::route('status-page'); }); /* |-------------------------------------------------------------------------- | Maintenance Mode Handler |-------------------------------------------------------------------------- | | The "down" Artisan command gives you the ability to put an application | into maintenance mode. Here, you will define what is displayed back | to the user if maintenance mode is in effect for the application.
public function validateToken() { return API::response()->array(['status' => 'success'])->statusCode(200); }