diff --git a/Desktop.Win/Services/ShutdownServiceWin.cs b/Desktop.Win/Services/ShutdownServiceWin.cs index a2bebb39..1b75f46d 100644 --- a/Desktop.Win/Services/ShutdownServiceWin.cs +++ b/Desktop.Win/Services/ShutdownServiceWin.cs @@ -6,6 +6,7 @@ using Remotely.Shared.Utilities; using System; using System.Diagnostics; using System.Threading.Tasks; +using System.Windows; namespace Remotely.Desktop.Win.Services { @@ -17,12 +18,12 @@ namespace Remotely.Desktop.Win.Services var casterSocket = ServiceContainer.Instance.GetRequiredService(); await casterSocket.DisconnectAllViewers(); await casterSocket.Disconnect(); - System.Windows.Forms.Application.Exit(); - App.Current.Dispatcher.Invoke(() => + Application.Current.Dispatcher.Invoke(() => { - App.Current.Shutdown(); - + Application.Current.Shutdown(); }); + System.Windows.Forms.Application.Exit(); + Environment.Exit(0); } } } diff --git a/Server/Hubs/ViewerHub.cs b/Server/Hubs/ViewerHub.cs index 2cc1bb55..3781b0a0 100644 --- a/Server/Hubs/ViewerHub.cs +++ b/Server/Hubs/ViewerHub.cs @@ -99,6 +99,11 @@ namespace Remotely.Server.Hubs public Task SendDtoToClient(byte[] baseDto) { + if (string.IsNullOrWhiteSpace(ScreenCasterID)) + { + return Task.CompletedTask; + } + return CasterHubContext.Clients.Client(ScreenCasterID).SendAsync("SendDtoToClient", baseDto, Context.ConnectionId); } @@ -109,7 +114,7 @@ namespace Remotely.Server.Hubs public override Task OnDisconnectedAsync(Exception exception) { - if (ScreenCasterID != null) + if (!string.IsNullOrWhiteSpace(ScreenCasterID)) { CasterHubContext.Clients.Client(ScreenCasterID).SendAsync("ViewerDisconnected", Context.ConnectionId); } @@ -129,6 +134,11 @@ namespace Remotely.Server.Hubs public async Task SendScreenCastRequestToDevice(string screenCasterID, string requesterName, int remoteControlMode, string otp) { + if (string.IsNullOrWhiteSpace(screenCasterID)) + { + return; + } + if ((RemoteControlMode)remoteControlMode == RemoteControlMode.Normal) { if (!CasterHub.SessionInfoList.Any(x => x.Value.AttendedSessionID == screenCasterID)) diff --git a/Server/Services/DataService.cs b/Server/Services/DataService.cs index ad617f10..c3297677 100644 --- a/Server/Services/DataService.cs +++ b/Server/Services/DataService.cs @@ -486,11 +486,11 @@ namespace Remotely.Server.Services public bool DoesUserExist(string userName) { - if (userName == null) + if (string.IsNullOrWhiteSpace(userName)) { return false; } - return RemotelyContext.Users.Any(x => x.UserName == userName); + return RemotelyContext.Users.Any(x => x.UserName.Trim().ToLower() == userName.Trim().ToLower()); } public bool DoesUserHaveAccessToDevice(string deviceID, RemotelyUser remotelyUser) diff --git a/Shared/ViewModels/Organization/Invite.cs b/Shared/ViewModels/Organization/Invite.cs index cfe9e0a7..72132d1a 100644 --- a/Shared/ViewModels/Organization/Invite.cs +++ b/Shared/ViewModels/Organization/Invite.cs @@ -1,4 +1,5 @@ using System; +using System.ComponentModel.DataAnnotations; namespace Remotely.Shared.ViewModels.Organization { @@ -7,6 +8,7 @@ namespace Remotely.Shared.ViewModels.Organization public string ID { get; set; } public bool IsAdmin { get; set; } public DateTimeOffset DateSent { get; set; } + [EmailAddress] public string InvitedUser { get; set; } } }