Skip to content

Commit

Permalink
Merge branch 'master' into alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed Mar 26, 2020
2 parents 869fe9a + 1326723 commit 78607a2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
8 changes: 3 additions & 5 deletions Server/API/RemoteControlController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Remotely.Server.Models;
using Remotely.Server.Services;
using Remotely.Server.Auth;
using Remotely.Shared.Helpers;

// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

Expand Down Expand Up @@ -100,12 +101,9 @@ private async Task<IActionResult> InitiateRemoteControl(string deviceID, string

var stopWatch = Stopwatch.StartNew();

while (!RCDeviceSocketHub.SessionInfoList.Values.Any(x => x.DeviceID == targetDevice.Value.ID && !existingSessions.Any(y => y.Key != x.RCDeviceSocketID)) && stopWatch.Elapsed.TotalSeconds < 5)
{
await Task.Delay(10);
}
Func<bool> remoteControlStarted = () => RCDeviceSocketHub.SessionInfoList.Values.Any(x => x.DeviceID == targetDevice.Value.ID && !existingSessions.Any(y => y.Key != x.RCDeviceSocketID));

if (!RCDeviceSocketHub.SessionInfoList.Values.Any(x => x.DeviceID == targetDevice.Value.ID && !existingSessions.Any(y => y.Key != x.RCDeviceSocketID)))
if (!await TaskHelper.DelayUntil(remoteControlStarted, TimeSpan.FromSeconds(15)))
{
return StatusCode(408, "The remote control process failed to start in time on the remote device.");
}
Expand Down
34 changes: 29 additions & 5 deletions Server/Areas/Identity/Pages/Account/Manage/ApiTokens.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@{
ViewData["Title"] = "API Access Tokens";
}

<h4>@ViewData["Title"]</h4>

@if (!string.IsNullOrWhiteSpace(Model.Message))
Expand All @@ -27,11 +28,12 @@

@if (Model.IsAdmin)
{
<form method="post" asp-page-handler="Create" class="mb-2 mt-4">
<label class="mr-1">New Token Name:</label>
<input class="form-control form-control-sm custom-control-inline mr-1" style="width:200px" asp-for="Input.TokenName" />
<button class="btn btn-primary" type="submit">Create</button>
</form>
<form method="post" asp-page-handler="Create" class="mb-2 mt-4">
<label class="mr-1">New Token Name:</label>
<input class="form-control form-control-sm custom-control-inline mr-1" style="width:200px" asp-for="Input.TokenName" />
<button class="btn btn-primary" type="submit">Create</button>
<span data-toggle="modal" data-target="#apiTokensModal" class="fas fa-question-circle pointer"></span>
</form>

<table class="table table-hover table-striped">
<thead>
Expand Down Expand Up @@ -68,6 +70,28 @@
</tbody>
</table>

<div id="apiTokensModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Using API Tokens</h5>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
</div>
<div class="modal-body">
<p>
API tokens should be added to the request header when making API calls. The key should be "Authorization", and value should be "{token}:{secret}".
</p>
<p>
Example: <span class="code">Authorization=e5da1c09-e851-4bd4-a8c1-532144b3f894:2xbA3TLPodNTVNAK+d7Cr3mK6o8CtSCT</span>
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>

<script type="module" src="~/scripts/Pages/ApiTokens.js">
</script>

Expand Down

0 comments on commit 78607a2

Please sign in to comment.