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-26 10:55:44 +0300
committerShlomo Hecht <shlomo@twine-s.com>2018-08-26 10:55:44 +0300
commit6e2fbaffeec9d6e3518ea9706eea107a4f1b348c (patch)
treef50b3d8962dd37188061f8f52c1a7aeff1642232 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoginViewVM.cs
parentdb3dc558ec5fe5f3584081795865cd22f912da7d (diff)
parente6704dce7a2b7f6d5f9bbf1b8374cc7f00ea061e (diff)
downloadTango-6e2fbaffeec9d6e3518ea9706eea107a4f1b348c.tar.gz
Tango-6e2fbaffeec9d6e3518ea9706eea107a4f1b348c.zip
merge
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();
+ }
}
}
}