Apply fixes from StyleCI
This commit is contained in:
parent
a1d3bbf73d
commit
c1fb0a665f
150 changed files with 1558 additions and 1760 deletions
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>
|
||||
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -21,27 +21,24 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Server;
|
||||
|
||||
use DB;
|
||||
use Log;
|
||||
use Auth;
|
||||
use Alert;
|
||||
use Log;
|
||||
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Repositories\SubuserRepository;
|
||||
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Repositories\SubuserRepository;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
class SubuserController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Controller Constructor
|
||||
* Controller Constructor.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
@ -61,9 +58,8 @@ class SubuserController extends Controller
|
|||
'subusers' => Models\Subuser::select('subusers.*', 'users.email as a_userEmail')
|
||||
->join('users', 'users.id', '=', 'subusers.user_id')
|
||||
->where('server_id', $server->id)
|
||||
->get()
|
||||
->get(),
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
public function getView(Request $request, $uuid, $id)
|
||||
|
@ -76,7 +72,7 @@ class SubuserController extends Controller
|
|||
->where(DB::raw('md5(subusers.id)'), $id)->where('subusers.server_id', $server->id)
|
||||
->first();
|
||||
|
||||
if (!$subuser) {
|
||||
if (! $subuser) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
|
@ -85,7 +81,7 @@ class SubuserController extends Controller
|
|||
->where('user_id', $subuser->user_id)->where('server_id', $server->id)
|
||||
->get();
|
||||
|
||||
foreach($modelPermissions as &$perm) {
|
||||
foreach ($modelPermissions as &$perm) {
|
||||
$permissions[$perm->permission] = true;
|
||||
}
|
||||
|
||||
|
@ -99,17 +95,15 @@ class SubuserController extends Controller
|
|||
|
||||
public function postView(Request $request, $uuid, $id)
|
||||
{
|
||||
|
||||
$server = Models\Server::getByUUID($uuid);
|
||||
$this->authorize('edit-subuser', $server);
|
||||
|
||||
$subuser = Models\Subuser::where(DB::raw('md5(id)'), $id)->where('server_id', $server->id)->first();
|
||||
|
||||
try {
|
||||
|
||||
if (!$subuser) {
|
||||
if (! $subuser) {
|
||||
throw new DisplayException('Unable to locate a subuser by that ID.');
|
||||
} else if ($subuser->user_id === Auth::user()->id) {
|
||||
} elseif ($subuser->user_id === Auth::user()->id) {
|
||||
throw new DisplayException('You are not authorized to edit you own account.');
|
||||
}
|
||||
|
||||
|
@ -117,14 +111,14 @@ class SubuserController extends Controller
|
|||
$repo->update($subuser->id, [
|
||||
'permissions' => $request->input('permissions'),
|
||||
'server' => $server->id,
|
||||
'user' => $subuser->user_id
|
||||
'user' => $subuser->user_id,
|
||||
]);
|
||||
|
||||
Alert::success('Subuser permissions have successfully been updated.')->flash();
|
||||
} catch (DisplayValidationException $ex) {
|
||||
return redirect()->route('server.subusers.view', [
|
||||
'uuid' => $uuid,
|
||||
'id' => $id
|
||||
'id' => $id,
|
||||
])->withErrors(json_decode($ex->getMessage()));
|
||||
} catch (DisplayException $ex) {
|
||||
Alert::danger($ex->getMessage())->flash();
|
||||
|
@ -132,9 +126,10 @@ class SubuserController extends Controller
|
|||
Log::error($ex);
|
||||
Alert::danger('An unknown error occured while attempting to update this subuser.')->flash();
|
||||
}
|
||||
|
||||
return redirect()->route('server.subusers.view', [
|
||||
'uuid' => $uuid,
|
||||
'id' => $id
|
||||
'id' => $id,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -145,7 +140,7 @@ class SubuserController extends Controller
|
|||
|
||||
return view('server.users.new', [
|
||||
'server' => $server,
|
||||
'node' => Models\Node::find($server->node)
|
||||
'node' => Models\Node::find($server->node),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -157,12 +152,13 @@ class SubuserController extends Controller
|
|||
try {
|
||||
$repo = new SubuserRepository;
|
||||
$id = $repo->create($server->id, $request->except([
|
||||
'_token'
|
||||
'_token',
|
||||
]));
|
||||
Alert::success('Successfully created new subuser.')->flash();
|
||||
|
||||
return redirect()->route('server.subusers.view', [
|
||||
'uuid' => $uuid,
|
||||
'id' => md5($id)
|
||||
'id' => md5($id),
|
||||
]);
|
||||
} catch (DisplayValidationException $ex) {
|
||||
return redirect()->route('server.subusers.new', $uuid)->withErrors(json_decode($ex->getMessage()))->withInput();
|
||||
|
@ -172,6 +168,7 @@ class SubuserController extends Controller
|
|||
Log::error($ex);
|
||||
Alert::danger('An unknown error occured while attempting to add a new subuser.')->flash();
|
||||
}
|
||||
|
||||
return redirect()->route('server.subusers.new', $uuid)->withInput();
|
||||
}
|
||||
|
||||
|
@ -182,23 +179,23 @@ class SubuserController extends Controller
|
|||
|
||||
try {
|
||||
$subuser = Models\Subuser::select('id')->where(DB::raw('md5(id)'), $id)->where('server_id', $server->id)->first();
|
||||
if (!$subuser) {
|
||||
if (! $subuser) {
|
||||
throw new DisplayException('No subuser by that ID was found on the system.');
|
||||
}
|
||||
|
||||
$repo = new SubuserRepository;
|
||||
$repo->delete($subuser->id);
|
||||
|
||||
return response('', 204);
|
||||
} catch (DisplayException $ex) {
|
||||
response()->json([
|
||||
'error' => $ex->getMessage()
|
||||
'error' => $ex->getMessage(),
|
||||
], 422);
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
response()->json([
|
||||
'error' => 'An unknown error occured while attempting to delete this subuser.'
|
||||
'error' => 'An unknown error occured while attempting to delete this subuser.',
|
||||
], 503);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Reference in a new issue