mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-17 05:43:45 +02:00
Improve server and user model code to accept a specific user
This commit is contained in:
@@ -176,13 +176,9 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
|
||||
return $server->daemonSecret;
|
||||
}
|
||||
|
||||
$subuser = Subuser::where('server_id', $server->id)->where('user_id', $this->id)->first();
|
||||
$subuser = $this->subuserOf->where('server_id', $server->id)->first();
|
||||
|
||||
if (is_null($subuser)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $subuser->daemonSecret;
|
||||
return ($subuser) ? $subuser->daemonSecret : null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -193,9 +189,9 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
|
||||
*/
|
||||
public function serverAccessArray()
|
||||
{
|
||||
$union = Subuser::select('server_id')->where('user_id', $this->id);
|
||||
|
||||
return Server::select('id')->where('owner_id', $this->id)->union($union)->pluck('id')->all();
|
||||
return Server::select('id')->where('owner_id', $this->id)->union(
|
||||
Subuser::select('server_id')->where('user_id', $this->id)
|
||||
)->pluck('id')->all();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user