Fixes some permissions stuff

This commit is contained in:
Dane Everitt 2016-01-08 22:22:57 -05:00
parent 71e6d2e1b6
commit b996316d92
4 changed files with 71 additions and 39 deletions

View file

@ -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();
}
}

View file

@ -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'
];
/**

View file

@ -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

View file

@ -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,6 +27,7 @@
</div>
<div class="col-md-6">
<hr />
@can('command', $server)
<form action="#" method="post" id="console_command" style="display:none;">
<fieldset>
<div class="input-group">
@ -38,15 +39,18 @@
</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 />
@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,6 +78,7 @@
</div>
</div>
</div>
@can('allocation', $server)
<div class="tab-pane" id="allocation">
<div class="panel panel-default">
<div class="panel-heading"></div>
@ -87,6 +92,7 @@
</div>
</div>
</div>
@endcan
</div>
<div class="row">
<div class="col-xs-11" id="col11_setter"></div>