From b9c104e259ca24d2ae7ca82387209779fefddd34 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sun, 19 Jan 2020 00:30:23 +0200 Subject: Implemented machine studio connection via access token WORKING!. Implemented machine studio login method selection. --- ...go.MachineStudio.Storage_yjpbed13_wpftmp.csproj | 154 +++++++++++++++++++++ .../Authentication/IAuthenticationProvider.cs | 2 +- .../MachineStudioSettings.cs | 6 + .../Tango.MachineStudio.Common.csproj | 3 +- .../Tango.MachineStudio.Common/Web/LoginMethod.cs | 17 +++ .../Tango.MachineStudio.Common/Web/LoginRequest.cs | 1 + .../DefaultAuthenticationProvider.cs | 3 +- .../Images/active_directory.png | Bin 0 -> 15300 bytes .../Tango.MachineStudio.UI/Images/login.png | Bin 0 -> 6401 bytes .../Images/machinestudio_login.png | Bin 0 -> 21788 bytes .../Tango.MachineStudio.UI.csproj | 5 +- .../ViewModels/LoginViewVM.cs | 29 +++- .../Tango.MachineStudio.UI/Views/LoginView.xaml | 76 ++++++---- .../Tango.MachineStudio.UI/Views/MainView.xaml | 2 +- 14 files changed, 265 insertions(+), 33 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Storage/Tango.MachineStudio.Storage_yjpbed13_wpftmp.csproj create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/LoginMethod.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/active_directory.png create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/login.png create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/machinestudio_login.png (limited to 'Software/Visual_Studio/MachineStudio') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Storage/Tango.MachineStudio.Storage_yjpbed13_wpftmp.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Storage/Tango.MachineStudio.Storage_yjpbed13_wpftmp.csproj new file mode 100644 index 000000000..698c6fe82 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Storage/Tango.MachineStudio.Storage_yjpbed13_wpftmp.csproj @@ -0,0 +1,154 @@ + + + + + Debug + AnyCPU + {5991F6B5-EA4E-41E9-A4F6-7D3A50010FD6} + library + Tango.MachineStudio.Storage + Tango.MachineStudio.Storage + v4.6.1 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + + + true + full + false + ..\..\..\Build\Machine Studio\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + ..\..\..\Build\Machine Studio\Release\ + TRACE + prompt + 4 + + + + + + GlobalVersionInfo.cs + + + + + + + + + + MainView.xaml + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + {f441feee-322a-4943-b566-110e12fd3b72} + Tango.BL + + + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} + Tango.Core + + + {4206ac58-3b57-4699-8835-90bf6db01a61} + Tango.Integration + + + {bc932dbd-7cdb-488c-99e4-f02cf441f55e} + Tango.Logging + + + {8491d07b-c1f6-4b62-a412-41b9fd2d6538} + Tango.SharedUI + + + {74e700b0-1156-4126-be40-ee450d3c3026} + Tango.Transport + + + {43135fb9-41db-4f87-9771-cf2c762027c0} + Tango.FirmwarePackageGenerator + + + {cb0b0aa2-bb24-4bca-a720-45e397684e12} + Tango.MachineStudio.Common + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/IAuthenticationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/IAuthenticationProvider.cs index 74969fd27..cb231fa05 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/IAuthenticationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Authentication/IAuthenticationProvider.cs @@ -29,7 +29,7 @@ namespace Tango.MachineStudio.Common.Authentication /// The email. /// The password. /// - AuthenticationLoginResult Login(String email, String password, bool bypassVersionCheck = false); + AuthenticationLoginResult Login(String email, String password, LoginMethod method, bool bypassVersionCheck = false); /// /// Logs-out the current logged-in user. diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs index 6ab26028f..91eaa857d 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/MachineStudioSettings.cs @@ -8,6 +8,7 @@ using System.Windows; using Tango.BL; using Tango.Integration.Operation; using Tango.Logging; +using Tango.MachineStudio.Common.Web; using Tango.PMR.Printing; using Tango.Settings; using Tango.Web; @@ -39,6 +40,11 @@ namespace Tango.MachineStudio.Common /// public String LastLoginPassword { get; set; } + /// + /// Gets or sets the last login method. + /// + public LoginMethod LastLoginMethod { get; set; } + /// /// Gets or sets a value indicating whether to save the user credentials. /// diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj index 5e874add1..2df984c7c 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj @@ -105,6 +105,7 @@ + @@ -426,7 +427,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/LoginMethod.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/LoginMethod.cs new file mode 100644 index 000000000..83f1c0850 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/LoginMethod.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Common.Web +{ + public enum LoginMethod + { + [Description("Active Directory")] + ActiveDirectory, + [Description("Standard User")] + StandardUser, + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/LoginRequest.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/LoginRequest.cs index 577f5e208..1727a2c6e 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/LoginRequest.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/LoginRequest.cs @@ -12,5 +12,6 @@ namespace Tango.MachineStudio.Common.Web public String Version { get; set; } public String Email { get; set; } public String Password { get; set; } + public LoginMethod Method { get; set; } } } 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 c992d0768..209b26505 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs @@ -90,7 +90,7 @@ namespace Tango.MachineStudio.UI.Authentication /// The password. /// /// Login failed for user " + email - public AuthenticationLoginResult Login(string email, string password, bool bypassVersionCheck = false) + public AuthenticationLoginResult Login(string email, string password, LoginMethod method, bool bypassVersionCheck = false) { _refreshTokenTimer.Stop(); @@ -118,6 +118,7 @@ namespace Tango.MachineStudio.UI.Authentication Email = email, Password = password, Version = appVersion, + Method = method, }).Result; } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/active_directory.png b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/active_directory.png new file mode 100644 index 000000000..4cced33e0 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/active_directory.png differ diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/login.png b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/login.png new file mode 100644 index 000000000..9f7d0b9ba Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/login.png differ diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/machinestudio_login.png b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/machinestudio_login.png new file mode 100644 index 000000000..98f1b286a Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Images/machinestudio_login.png differ diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj index 565489f0b..efe8fc6b1 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj @@ -363,6 +363,9 @@ TCC\template.bmp Always + + + @@ -676,7 +679,7 @@ if $(ConfigurationName) == Release RD /S /Q "$(TargetDir)Roslyn\" - + \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs index cf34764d9..9c2367f93 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs @@ -102,6 +102,21 @@ namespace Tango.MachineStudio.UI.ViewModels set { _enableSlotSelection = value; RaisePropertyChangedAuto(); } } + private bool _isActiveDirectory; + public bool IsActiveDirectory + { + get { return _isActiveDirectory; } + set { _isActiveDirectory = value; RaisePropertyChangedAuto(); if (value) IsStandardUser = false; } + } + + private bool _isStandardUser; + public bool IsStandardUser + { + get { return _isStandardUser; } + set { _isStandardUser = value; RaisePropertyChangedAuto(); if (value) IsActiveDirectory = false; } + } + + /// /// Gets or sets the login command. @@ -131,6 +146,15 @@ namespace Tango.MachineStudio.UI.ViewModels Email = _settings.LastLoginEmail; DeploymentSlot = _settings.DeploymentSlot; RememberMe = _settings.RememberMe; + + if (_settings.LastLoginMethod == LoginMethod.ActiveDirectory) + { + IsActiveDirectory = true; + } + else + { + IsStandardUser = true; + } try { @@ -154,11 +178,13 @@ namespace Tango.MachineStudio.UI.ViewModels IsLogging = true; InvalidateRelayCommands(); + LoginMethod loginMethod = IsActiveDirectory ? LoginMethod.ActiveDirectory : LoginMethod.StandardUser; + await Task.Factory.StartNew(() => { _settings.DeploymentSlot = DeploymentSlot; - LoginResponse result = _authenticationProvider.Login(Email, Password, _settings.ByPassEnvironmentVersionCheck).Response; + LoginResponse result = _authenticationProvider.Login(Email, Password, loginMethod, _settings.ByPassEnvironmentVersionCheck).Response; if (result.VersionChangeRequired && !_settings.ByPassEnvironmentVersionCheck) { @@ -183,6 +209,7 @@ namespace Tango.MachineStudio.UI.ViewModels _settings.LastLoginEmail = Email; _settings.RememberMe = RememberMe; + _settings.LastLoginMethod = loginMethod; _settings.LastLoginPassword = RememberMe ? cryptographer.Encrypt(Password) : null; _settings.Save(); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoginView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoginView.xaml index d93dbc127..e7428dd28 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoginView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/LoginView.xaml @@ -45,35 +45,57 @@ Machine Studio - - + + + + + + + + + + - - - Login to your account - - - - - - - - - - - - - - Environment selection requires restarting the application - Remember me - + - - - Logging you in... - - - + + + Login to your account + + + + + + + + + + + + + + + + + + Environment selection requires restarting the application + Remember me + + + + + Logging you in... + + + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml index 020343ba0..48f7b46d3 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml @@ -55,7 +55,7 @@ IsChecked="{Binding Source={x:Reference MenuToggleButton}, Path=IsChecked, Mode=TwoWay}" /> - + -- cgit v1.3.1