Support for server info and minor changes to API setup

This commit is contained in:
Dane Everitt 2016-10-20 16:42:54 -04:00
parent 5a03ce7e1a
commit 125856d92f
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
3 changed files with 64 additions and 3 deletions

View file

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