From 3ef3bccd7e18fdeae0e39ac6cec89066ffa661e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20B=C3=BCchel?= Date: Fri, 23 Oct 2020 09:31:23 +0200 Subject: [PATCH] SEBWIN-426: Ensured that lock screen is not activated when lock or switch session is allowed. --- SafeExamBrowser.Client/ClientController.cs | 38 +++++++++++++--------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/SafeExamBrowser.Client/ClientController.cs b/SafeExamBrowser.Client/ClientController.cs index 83a0438c..94e184fc 100644 --- a/SafeExamBrowser.Client/ClientController.cs +++ b/SafeExamBrowser.Client/ClientController.cs @@ -590,30 +590,38 @@ namespace SafeExamBrowser.Client private void SystemMonitor_SessionSwitched() { + var allow = !Settings.Service.IgnoreService && (!Settings.Service.DisableUserLock || !Settings.Service.DisableUserSwitch); var message = text.Get(TextKey.LockScreen_UserSessionMessage); var title = text.Get(TextKey.LockScreen_Title); var continueOption = new LockScreenOption { Text = text.Get(TextKey.LockScreen_UserSessionContinueOption) }; var terminateOption = new LockScreenOption { Text = text.Get(TextKey.LockScreen_UserSessionTerminateOption) }; - logger.Warn("Detected user session switch!"); - - if (!sessionLocked) + if (allow) { - sessionLocked = true; - - var result = ShowLockScreen(message, title, new[] { continueOption, terminateOption }); - - if (result.OptionId == terminateOption.Id) - { - logger.Info("Attempting to shutdown as requested by the user..."); - TryRequestShutdown(); - } - - sessionLocked = false; + logger.Info("Detected user session switch, but user lock and/or user switch are allowed."); } else { - logger.Info("Lock screen is already active."); + logger.Warn("Detected user session switch!"); + + if (!sessionLocked) + { + sessionLocked = true; + + var result = ShowLockScreen(message, title, new[] { continueOption, terminateOption }); + + if (result.OptionId == terminateOption.Id) + { + logger.Info("Attempting to shutdown as requested by the user..."); + TryRequestShutdown(); + } + + sessionLocked = false; + } + else + { + logger.Info("Lock screen is already active."); + } } }