Support for server info and minor changes to API setup
This commit is contained in:
parent
5a03ce7e1a
commit
125856d92f
3 changed files with 64 additions and 3 deletions
|
@ -27,6 +27,8 @@ use Auth;
|
|||
use Pterodactyl\Models\Subuser;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use Pterodactyl\Exception\DisplayException;
|
||||
|
||||
class Server extends Model
|
||||
{
|
||||
|
||||
|
@ -104,7 +106,7 @@ class Server extends Model
|
|||
* @param Illuminate\Database\Eloquent\Model\Server $server
|
||||
* @return string
|
||||
*/
|
||||
protected static function getUserDaemonSecret(Server $server)
|
||||
public static function getUserDaemonSecret(Server $server)
|
||||
{
|
||||
|
||||
if (self::$user->id === $server->owner || self::$user->root_admin === 1) {
|
||||
|
@ -174,7 +176,8 @@ class Server extends Model
|
|||
|
||||
$query = self::select('servers.*', 'services.file as a_serviceFile')
|
||||
->join('services', 'services.id', '=', 'servers.service')
|
||||
->where('uuidShort', $uuid);
|
||||
->where('uuidShort', $uuid)
|
||||
->orWhere('uuid', $uuid);
|
||||
|
||||
if (self::$user->root_admin !== 1) {
|
||||
$query->whereIn('servers.id', Subuser::accessServers());
|
||||
|
@ -182,6 +185,10 @@ class Server extends Model
|
|||
|
||||
$result = $query->first();
|
||||
|
||||
if (!$result) {
|
||||
throw new DisplayException('No server was found belonging to this user.');
|
||||
}
|
||||
|
||||
if(!is_null($result)) {
|
||||
$result->daemonSecret = self::getUserDaemonSecret($result);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue