aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2019-01-02 08:47:29 +0200
committerShlomo Hecht <shlomo@twine-s.com>2019-01-02 08:47:29 +0200
commit520e878bf98efcec9c75abcfe483175ff72620a2 (patch)
tree62a7221e3c22187821f6a5e399eca0f7bd31168a /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs
parent30574fe4a6e1bb4f60a43e9000acaf919811689a (diff)
parent25f5e6ddef7ef2fa0a747305847eeb4ceee5a2c9 (diff)
downloadTango-520e878bf98efcec9c75abcfe483175ff72620a2.tar.gz
Tango-520e878bf98efcec9c75abcfe483175ff72620a2.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs34
1 files changed, 28 insertions, 6 deletions
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 a37879a5e..492e23963 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs
@@ -6,6 +6,8 @@ using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Tango.BL;
+using Tango.BL.Enumerations;
using Tango.Core.Commands;
using Tango.Core.Cryptography;
using Tango.MachineStudio.Common;
@@ -15,6 +17,7 @@ using Tango.MachineStudio.Common.Navigation;
using Tango.MachineStudio.Common.Notifications;
using Tango.Settings;
using Tango.SharedUI;
+using Tango.Web;
namespace Tango.MachineStudio.UI.ViewModels
{
@@ -44,6 +47,9 @@ namespace Tango.MachineStudio.UI.ViewModels
}
private String _password;
+ /// <summary>
+ /// Gets or sets the password.
+ /// </summary>
[Required(ErrorMessage = "Password is required")]
public String Password
{
@@ -51,6 +57,16 @@ namespace Tango.MachineStudio.UI.ViewModels
set { _password = value; RaisePropertyChangedAuto(); }
}
+ private DeploymentSlot _deploymentSlot;
+ /// <summary>
+ /// Gets or sets the deployment slot.
+ /// </summary>
+ public DeploymentSlot DeploymentSlot
+ {
+ get { return _deploymentSlot; }
+ set { _deploymentSlot = value; RaisePropertyChangedAuto(); }
+ }
+
private bool _isLogging;
/// <summary>
/// Gets or sets a value indicating whether this instance is logging.
@@ -90,10 +106,11 @@ namespace Tango.MachineStudio.UI.ViewModels
_navigationManager = navigationManager;
_authenticationProvider = authenticationProvider;
_eventLogger = eventLogger;
- LoginCommand = new RelayCommand(Login,() => !IsLogging);
+ LoginCommand = new RelayCommand(Login, () => !IsLogging);
cryptographer = new Rfc2898Cryptographer();
Email = _settings.LastLoginEmail;
+ DeploymentSlot = _settings.DeploymentSlot;
RememberMe = _settings.RememberMe;
try
@@ -120,21 +137,26 @@ namespace Tango.MachineStudio.UI.ViewModels
await Task.Factory.StartNew(() =>
{
+ _settings.DeploymentSlot = DeploymentSlot;
+
_authenticationProvider.Login(Email, Password);
+
+ _eventLogger.Log(EventTypes.ApplicationStarted, "Application Started!");
+
_navigationManager.NavigateTo(NavigationView.MainView);
+
_settings.LastLoginEmail = Email;
_settings.RememberMe = RememberMe;
-
_settings.LastLoginPassword = RememberMe ? cryptographer.Encrypt(Password) : null;
_settings.Save();
- _eventLogger.Log("User logged in");
+ _eventLogger.Log("User logged in.");
});
}
- catch (Exception)
+ catch (Exception ex)
{
-
- _notificationProvider.ShowError("Invalid credentials. Please try again.");
+ LogManager.Log(ex, "Login Error.");
+ _notificationProvider.ShowError($"The specified email or password was incorrect, or you don't have a permission to run this application.\nError: {ex.FlattenMessage()}");
}
finally
{