1
1
mirror of https://github.com/pterodactyl/panel.git synced 2024-11-26 02:52:30 +01:00

Apply fixes from StyleCI (#372)

This commit is contained in:
Dane Everitt 2017-04-09 19:16:39 -04:00 committed by GitHub
parent 7bd14db646
commit 93d79994f8
22 changed files with 43 additions and 32 deletions

View File

@ -4,7 +4,6 @@ namespace Pterodactyl\Exceptions;
use Log;
use Exception;
use DisplayException;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;

View File

@ -27,8 +27,8 @@ namespace Pterodactyl\Http\Controllers\API\Admin;
use Fractal;
use Illuminate\Http\Request;
use Pterodactyl\Models\Node;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Repositories\NodeRepository;
use Pterodactyl\Transformers\Admin\NodeTransformer;
use Pterodactyl\Exceptions\DisplayValidationException;
@ -135,6 +135,7 @@ class NodeController extends Controller
], 400);
} catch (\Exception $ex) {
Log::error($ex);
return response()->json([
'error' => 'An unhandled exception occured while attemping to create this node. Please try again.',
], 500);
@ -163,6 +164,7 @@ class NodeController extends Controller
], 400);
} catch (\Exception $ex) {
Log::error($ex);
return response()->json([
'error' => 'An unhandled exception occured while attemping to delete this node. Please try again.',
], 500);

View File

@ -113,11 +113,13 @@ class ServerController extends Controller
], 400);
} catch (TransferException $ex) {
Log::warning($ex);
return response()->json([
'error' => 'A TransferException was encountered while trying to contact the daemon, please ensure it is online and accessible. This error has been logged.',
], 504);
} catch (\Exception $ex) {
Log::error($ex);
return response()->json([
'error' => 'An unhandled exception occured while attemping to add this server. Please try again.',
], 500);
@ -146,18 +148,20 @@ class ServerController extends Controller
], 400);
} catch (TransferException $ex) {
Log::warning($ex);
return response()->json([
'error' => 'A TransferException was encountered while trying to contact the daemon, please ensure it is online and accessible. This error has been logged.',
], 504);
} catch (\Exception $ex) {
Log::error($ex);
return response()->json([
'error' => 'An unhandled exception occured while attemping to add this server. Please try again.',
], 500);
}
}
/**
/**
* Update the details for a server.
*
* @param \Illuminate\Http\Request $request
@ -190,6 +194,7 @@ class ServerController extends Controller
], 400);
} catch (\Exception $ex) {
Log::error($ex);
return response()->json([
'error' => 'An unhandled exception occured while attemping to modify this server. Please try again.',
], 500);
@ -223,11 +228,13 @@ class ServerController extends Controller
], 400);
} catch (TransferException $ex) {
Log::warning($ex);
return response()->json([
'error' => 'A TransferException was encountered while trying to contact the daemon, please ensure it is online and accessible. This error has been logged.',
], 504);
} catch (\Exception $ex) {
Log::error($ex);
return response()->json([
'error' => 'An unhandled exception occured while attemping to modify this server container. Please try again.',
], 500);
@ -256,6 +263,7 @@ class ServerController extends Controller
], 400);
} catch (\Exception $ex) {
Log::error($ex);
return response()->json([
'error' => 'An unhandled exception occured while attemping to toggle the install status for this server. Please try again.',
], 500);
@ -283,6 +291,7 @@ class ServerController extends Controller
return response('', 204);
} catch (TransferException $ex) {
Log::warning($ex);
return response()->json([
'error' => 'A TransferException was encountered while trying to contact the daemon, please ensure it is online and accessible. This error has been logged.',
], 504);
@ -318,11 +327,13 @@ class ServerController extends Controller
], 400);
} catch (TransferException $ex) {
Log::warning($ex);
return response()->json([
'error' => 'A TransferException was encountered while trying to contact the daemon, please ensure it is online and accessible. This error has been logged.',
], 504);
} catch (\Exception $ex) {
Log::error($ex);
return response()->json([
'error' => 'An unhandled exception occured while attemping to ' . $action . ' this server. Please try again.',
], 500);
@ -363,11 +374,13 @@ class ServerController extends Controller
], 400);
} catch (TransferException $ex) {
Log::warning($ex);
return response()->json([
'error' => 'A TransferException was encountered while trying to contact the daemon, please ensure it is online and accessible. This error has been logged.',
], 504);
} catch (\Exception $ex) {
Log::error($ex);
return response()->json([
'error' => 'An unhandled exception occured while attemping to modify the build settings for this server. Please try again.',
], 500);
@ -400,11 +413,13 @@ class ServerController extends Controller
], 400);
} catch (TransferException $ex) {
Log::warning($ex);
return response()->json([
'error' => 'A TransferException was encountered while trying to contact the daemon, please ensure it is online and accessible. This error has been logged.',
], 504);
} catch (\Exception $ex) {
Log::error($ex);
return response()->json([
'error' => 'An unhandled exception occured while attemping to modify the startup settings for this server. Please try again.',
], 500);

View File

@ -27,8 +27,8 @@ namespace Pterodactyl\Http\Controllers\API\Admin;
use Fractal;
use Illuminate\Http\Request;
use Pterodactyl\Models\User;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Repositories\UserRepository;
use Pterodactyl\Transformers\Admin\UserTransformer;
use Pterodactyl\Exceptions\DisplayValidationException;
@ -109,6 +109,7 @@ class UserController extends Controller
], 400);
} catch (\Exception $ex) {
Log::error($ex);
return response()->json([
'error' => 'An unhandled exception occured while attemping to create this user. Please try again.',
], 500);
@ -145,6 +146,7 @@ class UserController extends Controller
], 400);
} catch (\Exception $ex) {
Log::error($ex);
return response()->json([
'error' => 'An unhandled exception occured while attemping to update this user. Please try again.',
], 500);
@ -173,6 +175,7 @@ class UserController extends Controller
], 400);
} catch (\Exception $ex) {
Log::error($ex);
return response()->json([
'error' => 'An unhandled exception occured while attemping to delete this user. Please try again.',
], 500);

View File

@ -27,10 +27,9 @@ namespace Pterodactyl\Http\Controllers\API\User;
use Fractal;
use Illuminate\Http\Request;
use Pterodactyl\Models\Server;
use GuzzleHttp\Exception\ConnectException;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Transformers\User\ServerTransformer;
use Pterodactyl\Repositories\Daemon\PowerRepository;
use Pterodactyl\Transformers\User\ServerTransformer;
class ServerController extends Controller
{

View File

@ -64,7 +64,7 @@ class CheckServer
$this->request = $request;
$this->server = Server::byUuid($request->route()->server);
if(! $this->exists()) {
if (! $this->exists()) {
return response()->view('errors.404', [], 404);
}
@ -124,6 +124,6 @@ class CheckServer
}
}
return ($this->server->installed === 1);
return $this->server->installed === 1;
}
}

View File

@ -28,13 +28,11 @@ use Auth;
use Crypt;
use Config;
use Closure;
use Response;
use Debugbar;
use IPTools\IP;
use IPTools\Range;
use Illuminate\Http\Request;
use Pterodactyl\Models\APIKey;
use Pterodactyl\Models\APIPermission;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; // 400
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; // 403
@ -150,7 +148,7 @@ class HMACAuthorization
protected function validateIPAccess()
{
if (! is_null($this->key()->allowed_ips)) {
foreach($this->key()->allowed_ips as $ip) {
foreach ($this->key()->allowed_ips as $ip) {
if (Range::parse($ip)->contains(new IP($this->request()->ip()))) {
return true;
}
@ -194,7 +192,8 @@ class HMACAuthorization
*
* @return string
*/
protected function public() {
protected function public()
{
return $this->token['public'];
}
@ -203,7 +202,8 @@ class HMACAuthorization
*
* @return string
*/
protected function hash() {
protected function hash()
{
return $this->token['hash'];
}
@ -212,7 +212,8 @@ class HMACAuthorization
*
* @return \Pterodactyl\Models\APIKey
*/
protected function key() {
protected function key()
{
return $this->key;
}

View File

@ -71,7 +71,7 @@ class APIPermission extends Model
'view',
'power',
'command',
]
],
],
// All other pemissions below are administrative actions.
@ -120,7 +120,7 @@ class APIPermission extends Model
];
/**
* Return permissions for API
* Return permissions for API.
*
* @return array
*/

View File

@ -209,7 +209,8 @@ class Server extends Model
*
* @return array
*/
public function getTableColumns() {
public function getTableColumns()
{
return Schema::getColumnListing($this->getTable());
}

View File

@ -66,7 +66,7 @@ class MacroServiceProvider extends ServiceProvider
return Cache::tags([
'ApiKeyMacro',
'ApiKeyMacro:Key:' . $parts[0],
])->remember('ApiKeyMacro.' . $parts[0], Carbon::now()->addMinutes(15), function() use ($parts) {
])->remember('ApiKeyMacro.' . $parts[0], Carbon::now()->addMinutes(15), function () use ($parts) {
return APIKey::where('public', $parts[0])->first();
});
}
@ -74,7 +74,7 @@ class MacroServiceProvider extends ServiceProvider
return false;
});
Request::macro('apiKeyHasPermission', function($permission) {
Request::macro('apiKeyHasPermission', function ($permission) {
$key = Request::apiKey();
if (! $key) {
return false;

View File

@ -31,8 +31,8 @@ use Validator;
use IPTools\Network;
use Pterodactyl\Models\User;
use Pterodactyl\Models\APIKey as Key;
use Pterodactyl\Models\APIPermission as Permission;
use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Models\APIPermission as Permission;
use Pterodactyl\Exceptions\DisplayValidationException;
class APIRepository

View File

@ -147,7 +147,7 @@ class UserRepository
unset($data['password']);
}
$user->fill($data)->save();;
$user->fill($data)->save();
return $user;
}

View File

@ -25,8 +25,8 @@
namespace Pterodactyl\Transformers\Admin;
use Illuminate\Http\Request;
use Pterodactyl\Models\ServiceVariable;
use League\Fractal\TransformerAbstract;
use Pterodactyl\Models\ServiceVariable;
class ServiceVariableTransformer extends TransformerAbstract
{

View File

@ -32,7 +32,7 @@ return [
'nodes' => env('APP_PAGINATE_API_NODES', 25),
'servers' => env('APP_PAGINATE_API_SERVERS', 25),
'users' => env('APP_PAGINATE_API_USERS', 25),
]
],
],
/*

View File

@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
Route::get('/', 'BaseController@getIndex')->name('admin.index');
/*

View File

@ -21,10 +21,8 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
Route::get('/', 'CoreController@index');
/*
|--------------------------------------------------------------------------
| Server Controller Routes

View File

@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
Route::get('/', 'CoreController@index')->name('api.user');
/*

View File

@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
Route::get('/logout', 'LoginController@logout')->name('auth.logout')->middleware('auth');
Route::get('/login', 'LoginController@showLoginForm')->name('auth.login');
Route::get('/login/totp', 'LoginController@totp')->name('auth.totp');

View File

@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
Route::get('/', 'IndexController@getIndex')->name('index');
Route::get('/index', function () {
redirect()->route('index');

View File

@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
Route::get('/services', 'ServiceController@list')->name('daemon.services');
Route::get('/services/pull/{service}/{file}', 'ServiceController@pull')->name('daemon.pull');
Route::get('/packs/pull/{uuid}', 'PackController@pull')->name('daemon.pack.pull');

View File

@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
Route::get('/configuration/{token}', 'RemoteController@getConfiguration')->name('remote.configuration');
Route::post('/download', 'RemoteController@postDownload')->name('remote.download');

View File

@ -21,7 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
Route::get('/', 'ServerController@getIndex')->name('server.index');
/*