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;
|
namespace Pterodactyl\Policies;
|
||||||
|
|
||||||
use Log;
|
|
||||||
use Debugbar;
|
|
||||||
use Pterodactyl\Models\User;
|
use Pterodactyl\Models\User;
|
||||||
use Pterodactyl\Models\Server;
|
use Pterodactyl\Models\Server;
|
||||||
|
|
||||||
|
@ -191,4 +189,36 @@ class ServerPolicy
|
||||||
return $user->permissions()->server($server)->permission('set-connection')->exists();
|
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;
|
namespace Pterodactyl\Providers;
|
||||||
|
|
||||||
use Pterodactyl\Models\Server;
|
|
||||||
use Pterodactyl\Policies\ServerPolicy;
|
|
||||||
|
|
||||||
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
|
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
|
||||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||||
|
|
||||||
|
@ -16,8 +13,7 @@ class AuthServiceProvider extends ServiceProvider
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $policies = [
|
protected $policies = [
|
||||||
'Pterodactyl\Model' => 'Pterodactyl\Policies\ModelPolicy',
|
'Pterodactyl\Models\Server' => 'Pterodactyl\Policies\ServerPolicy'
|
||||||
Server::class => ServerPolicy::class,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -193,9 +193,9 @@
|
||||||
<div class="list-group">
|
<div class="list-group">
|
||||||
<a href="#" class="list-group-item list-group-item-heading"><strong>{{ trans('pagination.sidebar.server_controls') }}</strong></a>
|
<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 }}/" 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>
|
@can('list-files', Auth::user())<a href="/server/{{ $server->uuidShort }}/files" class="list-group-item server-files">{{ trans('pagination.sidebar.files') }}</a>@endcan
|
||||||
<a href="/server/{{ $server->uuidShort }}/users" class="list-group-item server-users">{{ trans('pagination.sidebar.subusers') }}</a>
|
@can('view-subusers', Auth::user())<a href="/server/{{ $server->uuidShort }}/users" class="list-group-item server-users">{{ trans('pagination.sidebar.subusers') }}</a>@endcan
|
||||||
<a href="/server/{{ $server->uuidShort }}/settings" class="list-group-item server-settings">{{ trans('pagination.sidebar.manage') }}</a>
|
@can('view-manage', Auth::user())<a href="/server/{{ $server->uuidShort }}/settings" class="list-group-item server-settings">{{ trans('pagination.sidebar.manage') }}</a>@endcan
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
@show
|
@show
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<ul class="nav nav-tabs tabs_with_panel" id="config_tabs">
|
<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 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="#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>
|
</ul>
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<div class="tab-pane active" id="console">
|
<div class="tab-pane active" id="console">
|
||||||
|
@ -27,26 +27,30 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<hr />
|
<hr />
|
||||||
<form action="#" method="post" id="console_command" style="display:none;">
|
@can('command', $server)
|
||||||
<fieldset>
|
<form action="#" method="post" id="console_command" style="display:none;">
|
||||||
<div class="input-group">
|
<fieldset>
|
||||||
<input type="text" class="form-control" name="command" id="ccmd" placeholder="{{ trans('server.index.command') }}" />
|
<div class="input-group">
|
||||||
<span class="input-group-btn">
|
<input type="text" class="form-control" name="command" id="ccmd" placeholder="{{ trans('server.index.command') }}" />
|
||||||
<button id="sending_command" class="btn btn-primary btn-sm">→</button>
|
<span class="input-group-btn">
|
||||||
</span>
|
<button id="sending_command" class="btn btn-primary btn-sm">→</button>
|
||||||
</div>
|
</span>
|
||||||
</fieldset>
|
</div>
|
||||||
</form>
|
</fieldset>
|
||||||
<div class="alert alert-danger" id="sc_resp" style="display:none;margin-top: 15px;"></div>
|
</form>
|
||||||
|
<div class="alert alert-danger" id="sc_resp" style="display:none;margin-top: 15px;"></div>
|
||||||
|
@endcan
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6" style="text-align:center;">
|
<div class="col-md-6" style="text-align:center;">
|
||||||
<hr />
|
<hr />
|
||||||
<button class="btn btn-success btn-sm disabled" data-attr="power" data-action="start">Start</button>
|
@can('power', $server)
|
||||||
<button class="btn btn-primary btn-sm disabled" data-attr="power" data-action="restart">Restart</button>
|
<button class="btn btn-success btn-sm disabled" data-attr="power" data-action="start">Start</button>
|
||||||
<button class="btn btn-danger btn-sm disabled" data-attr="power" data-action="stop">Stop</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="kill"><i class="fa fa-ban" data-toggle="tooltip" data-placement="top" title="Kill Running Process"></i></button>
|
<button class="btn btn-danger btn-sm disabled" data-attr="power" data-action="stop">Stop</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>
|
<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>
|
||||||
<div id="pw_resp" style="display:none;margin-top: 15px;"></div>
|
<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>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
@ -74,19 +78,21 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane" id="allocation">
|
@can('allocation', $server)
|
||||||
<div class="panel panel-default">
|
<div class="tab-pane" id="allocation">
|
||||||
<div class="panel-heading"></div>
|
<div class="panel panel-default">
|
||||||
<div class="panel-body">
|
<div class="panel-heading"></div>
|
||||||
<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>
|
<div class="panel-body">
|
||||||
<ul class="nav nav-pills nav-stacked" id="conn_options">
|
<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>
|
||||||
@foreach ($allocations as $allocation)
|
<ul class="nav nav-pills nav-stacked" id="conn_options">
|
||||||
<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>
|
@foreach ($allocations as $allocation)
|
||||||
@endforeach
|
<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>
|
||||||
</ul>
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
@endcan
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-11" id="col11_setter"></div>
|
<div class="col-xs-11" id="col11_setter"></div>
|
||||||
|
|
Loading…
Reference in a new issue