diff --git a/TGS.Interface/Wrappers/IInstance.cs b/TGS.Interface/Wrappers/IInstance.cs
index a6895998d9..81db529014 100644
--- a/TGS.Interface/Wrappers/IInstance.cs
+++ b/TGS.Interface/Wrappers/IInstance.cs
@@ -13,7 +13,12 @@ namespace TGS.Interface.Wrappers
InstanceMetadata Metadata { get; }
///
- /// The component
+ /// Check if the connected user is an administrator of the
+ ///
+ bool UserIsAdministrator { get; }
+
+ ///
+ /// The component. Will be if is
///
ITGAdministration Administration { get; }
diff --git a/TGS.Interface/Wrappers/IServer.cs b/TGS.Interface/Wrappers/IServer.cs
index e06e7cb624..48ffc3d6cf 100644
--- a/TGS.Interface/Wrappers/IServer.cs
+++ b/TGS.Interface/Wrappers/IServer.cs
@@ -7,12 +7,12 @@ namespace TGS.Interface.Wrappers
///
/// Wrapper representing a
///
- public interface IServer : ITGSService
+ public interface IServer
{
///
/// The of the
///
- new Version Version { get; }
+ Version Version { get; }
///
/// Get the s the contains that the current user can access and connect to
@@ -20,10 +20,15 @@ namespace TGS.Interface.Wrappers
IEnumerable Instances { get; }
///
- /// The component
+ /// The component. Will be if the connected user is not an administrator of the
///
ITGInstanceManager InstanceManager { get; }
+ ///
+ /// The component. Will be if the connected user is not an administrator of the
+ ///
+ ITGSService Management { get; }
+
///
/// Gets the specified without connectivity checks
///
diff --git a/TGS.Interface/Wrappers/Instance.cs b/TGS.Interface/Wrappers/Instance.cs
index 72d9e364b4..f90d2202c8 100644
--- a/TGS.Interface/Wrappers/Instance.cs
+++ b/TGS.Interface/Wrappers/Instance.cs
@@ -14,6 +14,10 @@ namespace TGS.Interface.Wrappers
/// The name of the
///
InstanceMetadata metadata;
+ ///
+ /// Whether or not the current user is known to be an administrator of the
+ ///
+ bool isAdministrator;
///
/// Construct an
@@ -41,8 +45,28 @@ namespace TGS.Interface.Wrappers
}
}
+ public bool UserIsAdministrator { get
+ {
+ lock (this)
+ {
+ if (isAdministrator)
+ return true;
+ try
+ {
+ Administration.GetCurrentAuthorizedGroup();
+ isAdministrator = true;
+ return true;
+ }
+ catch
+ {
+ return false;
+ }
+ }
+ }
+ }
+
///
- public ITGAdministration Administration => serverInterface.GetComponent(metadata.Name);
+ public ITGAdministration Administration => UserIsAdministrator ? serverInterface.GetComponent(metadata.Name) : null;
///
public ITGByond Byond => serverInterface.GetComponent(metadata.Name);
diff --git a/TGS.Interface/Wrappers/Server.cs b/TGS.Interface/Wrappers/Server.cs
index 71b918ffe2..a826b623f4 100644
--- a/TGS.Interface/Wrappers/Server.cs
+++ b/TGS.Interface/Wrappers/Server.cs
@@ -35,10 +35,37 @@ namespace TGS.Interface.Wrappers
///
public ITGInstanceManager InstanceManager => serverInterface.GetComponent(null);
+ ///
+ public ITGSService Management
+ {
+ get
+ {
+ var component = serverInterface.GetComponent(null);
+ lock (this)
+ {
+ if (!userIsAdministrator)
+ try
+ {
+ var test = component.Version();
+ userIsAdministrator = true;
+ }
+ catch
+ {
+ return null;
+ }
+ }
+ return component;
+ }
+ }
+
///
/// The backing
///
readonly ServerInterface serverInterface;
+ ///
+ /// If the connected user is an administrator of the
+ ///
+ bool userIsAdministrator;
///
/// Result of a call to
@@ -59,41 +86,5 @@ namespace TGS.Interface.Wrappers
{
return new Instance(serverInterface, new InstanceMetadata { Name = name, Enabled = false });
}
-
- ///
- public void PrepareForUpdate()
- {
- serverInterface.GetComponent(null).PrepareForUpdate();
- }
-
- ///
- public string PythonPath()
- {
- return serverInterface.GetComponent(null).PythonPath();
- }
-
- ///
- public ushort RemoteAccessPort()
- {
- return serverInterface.GetComponent(null).RemoteAccessPort();
- }
-
- ///
- public bool SetPythonPath(string path)
- {
- return serverInterface.GetComponent(null).SetPythonPath(path);
- }
-
- ///
- public string SetRemoteAccessPort(ushort port)
- {
- return serverInterface.GetComponent(null).SetRemoteAccessPort(port);
- }
-
- ///
- string ITGSService.Version()
- {
- return serverInterface.GetComponent(null).Version();
- }
}
}