public async Task <IActionResult> Post([FromBody] RemoteControlRequest rcRequest) { if (!AppConfig.AllowApiLogin) { return(NotFound()); } var orgId = DataService.GetUserByNameWithOrg(rcRequest.Email)?.OrganizationID; var result = await SignInManager.PasswordSignInAsync(rcRequest.Email, rcRequest.Password, false, true); if (result.Succeeded && DataService.DoesUserHaveAccessToDevice(rcRequest.DeviceID, DataService.GetUserByNameWithOrg(rcRequest.Email))) { DataService.WriteEvent($"API login successful for {rcRequest.Email}.", orgId); return(await InitiateRemoteControl(rcRequest.DeviceID, orgId)); } else if (result.IsLockedOut) { DataService.WriteEvent($"API login unsuccessful due to lockout for {rcRequest.Email}.", orgId); return(Unauthorized("Account is locked.")); } else if (result.RequiresTwoFactor) { DataService.WriteEvent($"API login unsuccessful due to 2FA for {rcRequest.Email}.", orgId); return(Unauthorized("Account requires two-factor authentication.")); } DataService.WriteEvent($"API login unsuccessful due to bad attempt for {rcRequest.Email}.", orgId); return(BadRequest()); }
private void RemoteControl() { string consoleIp = sourceIP; if (consoleIp != "127.0.0.1") { var scRequest = new RemoteControlRequest(consoleIp, 5555); //launch VNC viewer on local computer scRequest.StartVncListerner(); var remoteControlMessage = new RequestMessage() { Request = scRequest, AgentId = CurrentEntity.ID }; var proxy = _container.Resolve <IMessageProxyInstance>(); proxy.Send(remoteControlMessage, OnRemoteControlCompleted); } else { MessageBox.Show("Cannot run Remote Control while connected through loopback interface (127.0.0.1)", "Oops", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }