From 72fc39f873de467c1431d928bce4d39442205691 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sun, 19 Oct 2025 16:20:01 +0300 Subject: MS LITE --- .../DefaultAuthenticationProvider.cs | 48 +++++++++++++++++++--- 1 file changed, 43 insertions(+), 5 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs index 26938b203..3b8e29bc8 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs @@ -19,6 +19,7 @@ using Tango.MachineStudio.Common.Web; using Tango.BL.Builders; using System.Data.Entity.Core; using System.Windows.Threading; +using Tango.MachineStudio.Common.Buid; namespace Tango.MachineStudio.UI.Authentication { @@ -31,6 +32,7 @@ namespace Tango.MachineStudio.UI.Authentication { private MachineStudioWebClient _client; private DispatcherTimer _refreshTokenTimer; + private IBuildProvider _buildProvider; private User _currentUser; /// @@ -47,6 +49,13 @@ namespace Tango.MachineStudio.UI.Authentication } } + private Machine _machine; + public Machine Machine + { + get { return _machine; } + set { _machine = value; RaisePropertyChangedAuto(); } + } + /// /// Occurs when the current logged-in user has changed. /// @@ -56,9 +65,10 @@ namespace Tango.MachineStudio.UI.Authentication /// Initializes a new instance of the class. /// /// The machine studio web client. - public DefaultAuthenticationProvider(MachineStudioWebClient machineStudioWebClient) + public DefaultAuthenticationProvider(MachineStudioWebClient machineStudioWebClient, IBuildProvider buildProvider) { _client = machineStudioWebClient; + _buildProvider = buildProvider; _refreshTokenTimer = new DispatcherTimer(); _refreshTokenTimer.Interval = TimeSpan.FromMinutes(30); @@ -90,7 +100,7 @@ namespace Tango.MachineStudio.UI.Authentication /// The password. /// /// Login failed for user " + email - public AuthenticationLoginResult Login(string email, string password, LoginMethod method, bool bypassVersionCheck = false, Action logAction = null) + public AuthenticationLoginResult Login(string email, string password, LoginMethod method, bool bypassVersionCheck = false, Action logAction = null, String serialNumber = null) { _refreshTokenTimer.Stop(); @@ -157,10 +167,20 @@ namespace Tango.MachineStudio.UI.Authentication try { - ObservablesStaticCollections.Instance.Initialize((x) => + if (_buildProvider.BuildType == MSBuildType.Default) { - logAction.Invoke(x); - }); + ObservablesStaticCollections.Instance.Initialize((x) => + { + logAction.Invoke(x); + }); + } + else + { + ObservablesStaticCollections.Instance.InitializeLite((x) => + { + logAction.Invoke(x); + }); + } } catch (Exception ex) { @@ -179,6 +199,24 @@ namespace Tango.MachineStudio.UI.Authentication CurrentUser = user; + if (_buildProvider.BuildType == MSBuildType.Lite) + { + var machine = new MachineBuilder(db).Set(x => x.SerialNumber.ToLower() == serialNumber.ToLower()).WithOrganization().Build(); + + if (machine == null) + { + throw new AuthenticationException($"Machine with serial number '{serialNumber}' could not be found."); + } + + if (machine.Organization.Guid != user.Organization.Guid) + { + throw new AuthenticationException($"You are not authorized to access the specified machine."); + } + + Machine = machine; + + } + _refreshTokenTimer.Start(); logAction.Invoke("Starting application..."); -- cgit v1.3.1