private async void btnLogin_Click(object sender, RoutedEventArgs e)
{
var email = txtEMail.Text;
var pwd = txtPwd.Password;
if (string.IsNullOrEmpty(email) && string.IsNullOrEmpty(pwd))
{
txtError.Text = "Please enter a EMail and a Password!";
return;
}
else if (string.IsNullOrEmpty(pwd))
{
txtError.Text = "Please enter a Password";
return;
}
else if (string.IsNullOrEmpty(email))
{
txtError.Text = "Please enter a EMail";
return;
}
txtError.Text = "";
IsEnabled = false;
_controller = await this.ShowProgressAsync("Logging in...", "Authenticating...");
_controller.SetIndeterminate();
var result = await Task.Factory.StartNew(() =>
{
return commander.AuthenticateUser(email, pwd);
});
txtPwd.Password = "";
await _controller.CloseAsync();
IsEnabled = true;
if (result == true)
{
await this.ShowMessageAsync("Authenticated", "Login success!");
MainWindow mainWindow = new MainWindow();
mainWindow.Show();
Close();
}
else
{
txtError.Text = "Combination of EMail and Password is incorrect!";
}
_controller.SetProgress(1);
}