aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs
diff options
context:
space:
mode:
authorRoy Ben Shabat <roy.mail.net@gmail.com>2025-10-19 16:20:01 +0300
committerRoy Ben Shabat <roy.mail.net@gmail.com>2025-10-19 16:20:01 +0300
commit72fc39f873de467c1431d928bce4d39442205691 (patch)
treefc92559db7b57bb44606e040cd8ed4bd34494256 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs
parent22ddd9e0b6efe5aef685c7fc9886e3d93cb350c0 (diff)
downloadTango-72fc39f873de467c1431d928bce4d39442205691.tar.gz
Tango-72fc39f873de467c1431d928bce4d39442205691.zip
MS LITE
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs48
1 files changed, 43 insertions, 5 deletions
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;
/// <summary>
@@ -47,6 +49,13 @@ namespace Tango.MachineStudio.UI.Authentication
}
}
+ private Machine _machine;
+ public Machine Machine
+ {
+ get { return _machine; }
+ set { _machine = value; RaisePropertyChangedAuto(); }
+ }
+
/// <summary>
/// Occurs when the current logged-in user has changed.
/// </summary>
@@ -56,9 +65,10 @@ namespace Tango.MachineStudio.UI.Authentication
/// Initializes a new instance of the <see cref="DefaultAuthenticationProvider"/> class.
/// </summary>
/// <param name="machineStudioWebClient">The machine studio web client.</param>
- 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
/// <param name="password">The password.</param>
/// <returns></returns>
/// <exception cref="AuthenticationException">Login failed for user " + email</exception>
- public AuthenticationLoginResult Login(string email, string password, LoginMethod method, bool bypassVersionCheck = false, Action<String> logAction = null)
+ public AuthenticationLoginResult Login(string email, string password, LoginMethod method, bool bypassVersionCheck = false, Action<String> 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...");