private async Task GetUserAsyc(EndpointCredential credential) { IsLoading = true; LoadingMessage = _resourceService.GetString("LoginLoadingMessage"); _dataService.Initialize(credential); var result = await _dataService.GetCurrentUser(); IsLoading = false; LoadingMessage = null; if (result.IsSuccessStatusCode && result.Result != null && result.Result.User != null) { CurrentUser = result.Result.User; EndpointUrl = null; UserName = null; Password = null; _navigationService.NavigateTo(ViewModelLocator.PROJECTS_PAGE_KEY, true, false); GetUsersIssues(); } else { await _dialogService.ShowError(_resourceService.GetString("LoginErrorMessage"), _resourceService.GetString("ErrorTitle"), _resourceService.GetString("ButtonOK"), null); return; } }
private async void Login() { // Validate input if (!ValidateCredentials(_endpointUrl, _userName, _password)) { await _dialogService.ShowError(_resourceService.GetString("LoginIncompleteErrorMessage"), _resourceService.GetString("ErrorTitle"), _resourceService.GetString("ButtonOK"), null); return; } var currentCredential = new EndpointCredential() { Name = DEFAULT_ENDPOINT_NAME, EndpointUrl = _endpointUrl, UserName = _userName, Password = _password }; // Save credentials if user didn't opt out if (_saveCredentials) { _credentialService.SaveEndpointCredential(currentCredential); } // try login await GetUserAsyc(currentCredential); }
public EndpointCredential GetEndpointCredential(string name) { try { var credentials = _vault.FindAllByResource(name); if (credentials != null && credentials.Count > 0) { var c = credentials.FirstOrDefault(); if (c != null) { c.RetrievePassword(); var endpointUrl = (String)_settingsService.GetSetting(name + ENDPOINT_URL_KEY); var ec = new EndpointCredential() { Name = name, EndpointUrl = endpointUrl, UserName = c.UserName, Password = c.Password }; return(ec); } } } catch { } return(null); }
public void SaveEndpointCredential(EndpointCredential ec) { var credentials = new PasswordCredential(ec.Name, ec.UserName, ec.Password); _settingsService.SetSetting(ec.Name + ENDPOINT_URL_KEY, ec.EndpointUrl); _vault.Add(credentials); }
public void Initialize(EndpointCredential endpointCredential) { _credential = endpointCredential; _httpService.Initialize(endpointCredential.UserName, endpointCredential.Password); if (!_credential.EndpointUrl.EndsWith("/")) { _credential.EndpointUrl += "/"; } }
private DataService CreateTestDataService() { var dataService = new DataService(new HttpService(), null); var credential = new EndpointCredential() { EndpointUrl = TEST_ENDPOINT, UserName = TEST_USER, Password = TEST_PASS }; dataService.Initialize(credential); return(dataService); }