Use permalinks on download page for organization's desktop client.

This commit is contained in:
Jared 2021-02-21 07:25:05 -08:00 committed by Jared Goodwin
parent d8597b6daa
commit 1643576ad1
3 changed files with 38 additions and 8 deletions

View File

@ -65,6 +65,32 @@ namespace Remotely.Server.API
}
}
[HttpGet("desktop/{platformId}/{organizationId}")]
public async Task<IActionResult> 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<IActionResult> GetInstaller(string platformID)
@ -95,13 +121,13 @@ namespace Remotely.Server.API
return File(fileBytes, "application/octet-stream", fileName);
}
private async Task<IActionResult> GetDesktopFile(string filePath)
private async Task<IActionResult> 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

View File

@ -14,7 +14,7 @@
<p>
<strong>Download:</strong>
<br />
<a href="/api/ClientDownloads/Desktop/WindowsDesktop-x64">Windows EXE</a>
<a href="/api/ClientDownloads/Desktop/WindowsDesktop-x64/@Model.OrganizationId">Windows EXE</a>
</p>
</div>
<div class="col-sm-6">
@ -22,7 +22,7 @@
<p>
<strong>Download:</strong>
<br />
<a href="/api/ClientDownloads/Desktop/WindowsDesktop-x86">Windows EXE</a>
<a href="/api/ClientDownloads/Desktop/WindowsDesktop-x86/@Model.OrganizationId">Windows EXE</a>
</p>
</div>
<div class="col-sm-6 mb-3">
@ -30,7 +30,7 @@
<p>
<strong>Download:</strong>
<br />
<a href="/api/ClientDownloads/Desktop/UbuntuDesktop">Ubuntu Executable</a>
<a href="/api/ClientDownloads/Desktop/UbuntuDesktop/@Model.OrganizationId">Ubuntu Executable</a>
</p>
</div>
</div>

View File

@ -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(