Fixes some permissions stuff
This commit is contained in:
parent
71e6d2e1b6
commit
b996316d92
4 changed files with 71 additions and 39 deletions
|
@ -2,8 +2,6 @@
|
|||
|
||||
namespace Pterodactyl\Policies;
|
||||
|
||||
use Log;
|
||||
use Debugbar;
|
||||
use Pterodactyl\Models\User;
|
||||
use Pterodactyl\Models\Server;
|
||||
|
||||
|
@ -191,4 +189,36 @@ class ServerPolicy
|
|||
return $user->permissions()->server($server)->permission('set-connection')->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user has permission to view subusers for the server.
|
||||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
*/
|
||||
public function viewSubusers(User $user, Server $server)
|
||||
{
|
||||
if ($this->isOwner($user, $server)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $user->permissions()->server($server)->permission('view-subusers')->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user has permission to view the server management page.
|
||||
*
|
||||
* @param Pterodactyl\Models\User $user
|
||||
* @param Pterodactyl\Models\Server $server
|
||||
* @return boolean
|
||||
*/
|
||||
public function viewManage(User $user, Server $server)
|
||||
{
|
||||
if ($this->isOwner($user, $server)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $user->permissions()->server($server)->permission('view-manage')->exists();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
|
||||
namespace Pterodactyl\Providers;
|
||||
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Policies\ServerPolicy;
|
||||
|
||||
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
|
||||
|
@ -16,8 +13,7 @@ class AuthServiceProvider extends ServiceProvider
|
|||
* @var array
|
||||
*/
|
||||
protected $policies = [
|
||||
'Pterodactyl\Model' => 'Pterodactyl\Policies\ModelPolicy',
|
||||
Server::class => ServerPolicy::class,
|
||||
'Pterodactyl\Models\Server' => 'Pterodactyl\Policies\ServerPolicy'
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
@ -193,9 +193,9 @@
|
|||
<div class="list-group">
|
||||
<a href="#" class="list-group-item list-group-item-heading"><strong>{{ trans('pagination.sidebar.server_controls') }}</strong></a>
|
||||
<a href="/server/{{ $server->uuidShort }}/" class="list-group-item server-index">{{ trans('pagination.sidebar.overview') }}</a>
|
||||
<a href="/server/{{ $server->uuidShort }}/files" class="list-group-item server-files">{{ trans('pagination.sidebar.files') }}</a>
|
||||
<a href="/server/{{ $server->uuidShort }}/users" class="list-group-item server-users">{{ trans('pagination.sidebar.subusers') }}</a>
|
||||
<a href="/server/{{ $server->uuidShort }}/settings" class="list-group-item server-settings">{{ trans('pagination.sidebar.manage') }}</a>
|
||||
@can('list-files', Auth::user())<a href="/server/{{ $server->uuidShort }}/files" class="list-group-item server-files">{{ trans('pagination.sidebar.files') }}</a>@endcan
|
||||
@can('view-subusers', Auth::user())<a href="/server/{{ $server->uuidShort }}/users" class="list-group-item server-users">{{ trans('pagination.sidebar.subusers') }}</a>@endcan
|
||||
@can('view-manage', Auth::user())<a href="/server/{{ $server->uuidShort }}/settings" class="list-group-item server-settings">{{ trans('pagination.sidebar.manage') }}</a>@endcan
|
||||
</div>
|
||||
@endif
|
||||
@show
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<ul class="nav nav-tabs tabs_with_panel" id="config_tabs">
|
||||
<li id="triggerConsoleView" class="active"><a href="#console" data-toggle="tab">{{ trans('server.index.control') }}</a></li>
|
||||
<li><a href="#stats" data-toggle="tab">{{ trans('server.index.usage') }}</a></li>
|
||||
<li><a href="#allocation" data-toggle="tab">{{ trans('server.index.allocation') }}</a></li>
|
||||
@can('allocation', $server)<li><a href="#allocation" data-toggle="tab">{{ trans('server.index.allocation') }}</a></li>@endcan
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="console">
|
||||
|
@ -27,26 +27,30 @@
|
|||
</div>
|
||||
<div class="col-md-6">
|
||||
<hr />
|
||||
<form action="#" method="post" id="console_command" style="display:none;">
|
||||
<fieldset>
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" name="command" id="ccmd" placeholder="{{ trans('server.index.command') }}" />
|
||||
<span class="input-group-btn">
|
||||
<button id="sending_command" class="btn btn-primary btn-sm">→</button>
|
||||
</span>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
<div class="alert alert-danger" id="sc_resp" style="display:none;margin-top: 15px;"></div>
|
||||
@can('command', $server)
|
||||
<form action="#" method="post" id="console_command" style="display:none;">
|
||||
<fieldset>
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" name="command" id="ccmd" placeholder="{{ trans('server.index.command') }}" />
|
||||
<span class="input-group-btn">
|
||||
<button id="sending_command" class="btn btn-primary btn-sm">→</button>
|
||||
</span>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
<div class="alert alert-danger" id="sc_resp" style="display:none;margin-top: 15px;"></div>
|
||||
@endcan
|
||||
</div>
|
||||
<div class="col-md-6" style="text-align:center;">
|
||||
<hr />
|
||||
<button class="btn btn-success btn-sm disabled" data-attr="power" data-action="start">Start</button>
|
||||
<button class="btn btn-primary btn-sm disabled" data-attr="power" data-action="restart">Restart</button>
|
||||
<button class="btn btn-danger btn-sm disabled" data-attr="power" data-action="stop">Stop</button>
|
||||
<button class="btn btn-danger btn-sm disabled" data-attr="power" data-action="kill"><i class="fa fa-ban" data-toggle="tooltip" data-placement="top" title="Kill Running Process"></i></button>
|
||||
<button class="btn btn-primary btn-sm" data-toggle="modal" data-target="#pauseConsole" id="pause_console"><small><i class="fa fa-pause fa-fw"></i></small></button>
|
||||
<div id="pw_resp" style="display:none;margin-top: 15px;"></div>
|
||||
@can('power', $server)
|
||||
<button class="btn btn-success btn-sm disabled" data-attr="power" data-action="start">Start</button>
|
||||
<button class="btn btn-primary btn-sm disabled" data-attr="power" data-action="restart">Restart</button>
|
||||
<button class="btn btn-danger btn-sm disabled" data-attr="power" data-action="stop">Stop</button>
|
||||
<button class="btn btn-danger btn-sm disabled" data-attr="power" data-action="kill"><i class="fa fa-ban" data-toggle="tooltip" data-placement="top" title="Kill Running Process"></i></button>
|
||||
<button class="btn btn-primary btn-sm" data-toggle="modal" data-target="#pauseConsole" id="pause_console"><small><i class="fa fa-pause fa-fw"></i></small></button>
|
||||
<div id="pw_resp" style="display:none;margin-top: 15px;"></div>
|
||||
@endcan
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
@ -74,19 +78,21 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="allocation">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading"></div>
|
||||
<div class="panel-body">
|
||||
<div class="alert alert-info">Below is a listing of all avaliable IPs and Ports for your service. To change the default connection address for your server, simply click on the one you would like to make default below.</div>
|
||||
<ul class="nav nav-pills nav-stacked" id="conn_options">
|
||||
@foreach ($allocations as $allocation)
|
||||
<li role="presentation" @if($allocation->ip === $server->ip && $allocation->port === $server->port) class="active" @endif><a href="#/set-connnection/{{ $allocation->ip }}:{{ $allocation->port }}" data-action="set-connection" data-connection="{{ $allocation->ip }}:{{ $allocation->port }}">{{ $allocation->ip }} <span class="badge">{{ $allocation->port }}</span></a></li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@can('allocation', $server)
|
||||
<div class="tab-pane" id="allocation">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading"></div>
|
||||
<div class="panel-body">
|
||||
<div class="alert alert-info">Below is a listing of all avaliable IPs and Ports for your service. To change the default connection address for your server, simply click on the one you would like to make default below.</div>
|
||||
<ul class="nav nav-pills nav-stacked" id="conn_options">
|
||||
@foreach ($allocations as $allocation)
|
||||
<li role="presentation" @if($allocation->ip === $server->ip && $allocation->port === $server->port) class="active" @endif><a href="#/set-connnection/{{ $allocation->ip }}:{{ $allocation->port }}" data-action="set-connection" data-connection="{{ $allocation->ip }}:{{ $allocation->port }}">{{ $allocation->ip }} <span class="badge">{{ $allocation->port }}</span></a></li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endcan
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-11" id="col11_setter"></div>
|
||||
|
|
Loading…
Reference in a new issue