Skip to content

Commit

Permalink
Create default debug org.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed Jul 26, 2023
1 parent a3a1ad5 commit 2ac886a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
5 changes: 2 additions & 3 deletions Agent/Services/AgentHubConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,12 @@ public AgentHubConnection(
public async Task Connect()
{
using var throttle = new SemaphoreSlim(1, 1);
var count = 1;

while (true)
for (var i = 1; true; i++)
{
try
{
var waitSeconds = Math.Min(60, Math.Pow(count, 2));
var waitSeconds = Math.Min(60, Math.Pow(i, 2));
// This will allow the first attempt to go through immediately, but
// subsequent attempts will have an exponential delay.
_ = await throttle.WaitAsync(TimeSpan.FromSeconds(waitSeconds));
Expand Down
3 changes: 2 additions & 1 deletion Agent/Services/ConfigService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Immense.RemoteControl.Shared;
using Microsoft.Extensions.Logging;
using Remotely.Shared;
using Remotely.Shared.Models;
using Remotely.Shared.Utilities;
using System;
Expand Down Expand Up @@ -81,7 +82,7 @@ public ConnectionInfo GetConnectionInfo()
{
DeviceID = _debugGuid,
Host = "http://localhost:5000",
OrganizationID = orgID
OrganizationID = AppConstants.DebugOrgId
};
}

Expand Down
17 changes: 16 additions & 1 deletion Server/Areas/Identity/Pages/Account/Register.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.UI.Services;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Remotely.Server.Services;
using Remotely.Shared;
using Remotely.Shared.Models;

namespace Remotely.Server.Areas.Identity.Pages.Account;
Expand All @@ -26,6 +29,7 @@ public class RegisterModel : PageModel
private readonly ILogger<RegisterModel> _logger;
private readonly IEmailSenderEx _emailSender;
private readonly IDataService _dataService;
private readonly IWebHostEnvironment _hostEnvironment;
private readonly IApplicationConfig _appConfig;

public RegisterModel(
Expand All @@ -34,13 +38,15 @@ public RegisterModel(
ILogger<RegisterModel> logger,
IEmailSenderEx emailSender,
IDataService dataService,
IWebHostEnvironment hostEnvironment,
IApplicationConfig appConfig)
{
_userManager = userManager;
_signInManager = signInManager;
_logger = logger;
_emailSender = emailSender;
_dataService = dataService;
_hostEnvironment = hostEnvironment;
_appConfig = appConfig;
}

Expand Down Expand Up @@ -95,12 +101,21 @@ public async Task<IActionResult> OnPostAsync(string? returnUrl = null)
UserName = Input.Email,
Email = Input.Email,
IsServerAdmin = organizationCount == 0,
Organization = new Organization() { OrganizationName = "Test Org" },
Organization = new Organization()
{
OrganizationName = string.Empty,
IsDefaultOrganization = organizationCount == 0
},
UserOptions = new RemotelyUserOptions(),
IsAdministrator = true,
LockoutEnabled = true
};

if (organizationCount == 0 && _hostEnvironment.IsDevelopment())
{
user.Organization.ID = AppConstants.DebugOrgId;
}

var result = await _userManager.CreateAsync(user, Input.Password);
if (result.Succeeded)
{
Expand Down
1 change: 1 addition & 0 deletions Shared/AppConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class AppConstants
{
public const string DefaultProductName = "Remotely";
public const string DefaultPublisherName = "Immense Networks";
public const string DebugOrgId = "e8f4ad87-4a4b-4da1-bcb2-1788eaeb80e8";
public const int EmbeddedDataBlockLength = 256;
public const long MaxUploadFileSize = 100_000_000;
public const double ScriptRunExpirationMinutes = 30;
Expand Down

0 comments on commit 2ac886a

Please sign in to comment.