private async void ButtonLogin_OnClicked(object sender, EventArgs e) { ViewModel.IsLoggingIn = true; ViewModel.Status = "Logging in..."; ViewModel.StatusDetail = null; string userName = ViewModel.UserName; string password = ViewModel.Password; DijnetLoginResult loginResult = await authClient.LoginAsync(userName, password); if (loginResult.Success) { bool remember = ViewModel.Remember; bool autoLogin = ViewModel.AutoLogin; DijnetCredential credential = new DijnetCredential(userName, password, remember, autoLogin); await credentialManager.UpdateCredentialAsync(credential); await OnLoginSuccess(loginResult.CookieContainer, loginResult.Url); } else { ViewModel.Status = "Failed to log in!"; ViewModel.StatusDetail = loginResult.Error; ViewModel.IsLoggingIn = false; } }
private async Task <bool> TryAutoLoginAsync(DijnetCredential dijnetCredential) { if (dijnetCredential.IsValid && dijnetCredential.AutoLogin) { ViewModel.Status = "Logging in..."; DijnetLoginResult loginResult = await authClient.LoginAsync(dijnetCredential.UserName, dijnetCredential.Password); if (loginResult.Success) { await OnLoginSuccess(loginResult.CookieContainer, loginResult.Url); return(true); } } return(false); }