diff --git a/Server/API/ClientDownloadsController.cs b/Server/API/ClientDownloadsController.cs index 1171ec51..3928af11 100644 --- a/Server/API/ClientDownloadsController.cs +++ b/Server/API/ClientDownloadsController.cs @@ -65,6 +65,32 @@ namespace Remotely.Server.API } } + + [HttpGet("desktop/{platformId}/{organizationId}")] + public async Task GetDesktop(string platformId, string organizationId) + { + switch (platformId) + { + case "WindowsDesktop-x64": + { + var filePath = Path.Combine(_hostEnv.WebRootPath, "Downloads", "Win-x64", "Remotely_Desktop.exe"); + return await GetDesktopFile(filePath, organizationId); + } + case "WindowsDesktop-x86": + { + var filePath = Path.Combine(_hostEnv.WebRootPath, "Downloads", "Win-x86", "Remotely_Desktop.exe"); + return await GetDesktopFile(filePath, organizationId); + } + case "UbuntuDesktop": + { + var filePath = Path.Combine(_hostEnv.WebRootPath, "Downloads", "Remotely_Desktop"); + return await GetDesktopFile(filePath, organizationId); + } + default: + return NotFound(); + } + } + [ServiceFilter(typeof(ApiAuthorizationFilter))] [HttpGet("{platformID}")] public async Task GetInstaller(string platformID) @@ -95,13 +121,13 @@ namespace Remotely.Server.API return File(fileBytes, "application/octet-stream", fileName); } - private async Task GetDesktopFile(string filePath) + private async Task GetDesktopFile(string filePath, string organizationId = null) { string relayCode; - if (User.Identity.IsAuthenticated) + if (!string.IsNullOrWhiteSpace(organizationId)) { - var currentOrg = await _dataService.GetOrganizationByUserName(User.Identity.Name); + var currentOrg = _dataService.GetOrganizationById(organizationId); relayCode = currentOrg.RelayCode; } else diff --git a/Server/Pages/Agents.cshtml b/Server/Pages/Agents.cshtml index 54e42d38..4415cd05 100644 --- a/Server/Pages/Agents.cshtml +++ b/Server/Pages/Agents.cshtml @@ -14,7 +14,7 @@

Download:
- Windows EXE + Windows EXE

@@ -22,7 +22,7 @@

Download:
- Windows EXE + Windows EXE

@@ -30,7 +30,7 @@

Download:
- Ubuntu Executable + Ubuntu Executable

diff --git a/Server/Pages/Agents.cshtml.cs b/Server/Pages/Agents.cshtml.cs index 28a56f44..e92fd55a 100644 --- a/Server/Pages/Agents.cshtml.cs +++ b/Server/Pages/Agents.cshtml.cs @@ -25,7 +25,7 @@ namespace Remotely.Server.Pages _hostEnvironment = hostEnvironment; } - public Organization CurrentOrganization { get; private set; } + public string OrganizationId { get; private set; } public bool IsServerUrlEmbedded { get; private set; } public async Task OnGet() @@ -33,7 +33,11 @@ namespace Remotely.Server.Pages if (User.Identity.IsAuthenticated) { var currentUser = await _userManager.GetUserAsync(User); - CurrentOrganization = _dataService.GetOrganizationById(currentUser.OrganizationID); + OrganizationId = _dataService.GetOrganizationById(currentUser.OrganizationID)?.ID; + } + else + { + OrganizationId = (await _dataService.GetDefaultOrganization())?.ID; } var appFilePath = Path.Combine(