aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2018-08-23 14:52:22 +0300
committerShlomo Hecht <shlomo@twine-s.com>2018-08-23 14:52:22 +0300
commit4e81425d99f39b8edc10660d72566c6c1408810d (patch)
tree16e93ce35705611e02684c8e8d45b9ce40fbee3e /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs
parent09c780fd78c43291f7298f854770fbb47d014f02 (diff)
downloadTango-4e81425d99f39b8edc10660d72566c6c1408810d.tar.gz
Tango-4e81425d99f39b8edc10660d72566c6c1408810d.zip
changes on other computers
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.cs41
1 files changed, 31 insertions, 10 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 f2a4f1143..a37879a5e 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs
@@ -51,6 +51,15 @@ namespace Tango.MachineStudio.UI.ViewModels
set { _password = value; RaisePropertyChangedAuto(); }
}
+ private bool _isLogging;
+ /// <summary>
+ /// Gets or sets a value indicating whether this instance is logging.
+ /// </summary>
+ public bool IsLogging
+ {
+ get { return _isLogging; }
+ set { _isLogging = value; RaisePropertyChangedAuto(); }
+ }
private bool _rememberMe;
/// <summary>
@@ -81,7 +90,7 @@ namespace Tango.MachineStudio.UI.ViewModels
_navigationManager = navigationManager;
_authenticationProvider = authenticationProvider;
_eventLogger = eventLogger;
- LoginCommand = new RelayCommand(Login);
+ LoginCommand = new RelayCommand(Login,() => !IsLogging);
cryptographer = new Rfc2898Cryptographer();
Email = _settings.LastLoginEmail;
@@ -100,26 +109,38 @@ namespace Tango.MachineStudio.UI.ViewModels
/// <summary>
/// Logins the requested user.
/// </summary>
- private void Login()
+ private async void Login()
{
if (Validate())
{
try
{
- _authenticationProvider.Login(Email, Password);
- _navigationManager.NavigateTo(NavigationView.MainView);
- _settings.LastLoginEmail = Email;
- _settings.RememberMe = RememberMe;
+ IsLogging = true;
+ InvalidateRelayCommands();
- _settings.LastLoginPassword = RememberMe ? cryptographer.Encrypt(Password) : null;
- _settings.Save();
+ await Task.Factory.StartNew(() =>
+ {
+ _authenticationProvider.Login(Email, Password);
+ _navigationManager.NavigateTo(NavigationView.MainView);
+ _settings.LastLoginEmail = Email;
+ _settings.RememberMe = RememberMe;
- _eventLogger.Log("User logged in");
+ _settings.LastLoginPassword = RememberMe ? cryptographer.Encrypt(Password) : null;
+ _settings.Save();
+
+ _eventLogger.Log("User logged in");
+ });
}
- catch
+ catch (Exception)
{
+
_notificationProvider.ShowError("Invalid credentials. Please try again.");
}
+ finally
+ {
+ IsLogging = false;
+ InvalidateRelayCommands();
+ }
}
}
}