public static function slimCallback(Slim $slim) { $user = new UserAuth(); $isValidCsrfToken = $user->checkCsrfToken($slim->request->headers->get('X-Ema-Csrftoken')); if (!$isValidCsrfToken) { throw new RuntimeException('CSRF token not valid'); } if (isset($_POST['action']) === false) { throw new RuntimeException("Invalid Request"); } if ($_POST['action'] === "standardMethod") { return self::standardMethodCall(); } else { return self::otherCalls(); } }
public static function rpcCheckAndRun(RpcCall $rpc, Slim $slim) { $localization = $slim->request->headers->get('Ema-Localization'); if ($localization) { $rpc->setLocalization($localization); } $user = new UserAuth(); $isValidCsrfToken = $user->checkCsrfToken($slim->request->headers->get('X-Ema-Csrftoken')); if (!$isValidCsrfToken) { throw new InputError('CSRF token not valid'); } $result = $rpc->run(); if (self::$isAddition) { self::$additionRouteBase .= $result; } if (self::$isGettingItem && empty($result)) { throw new NotFound('Item not found'); } return $result; }