public async Task <UserAndToken> Login(LocalCredentials credentials) { if (credentials == null) { throw new ArgumentException("valid LocalCredentials are needed to login."); } Parent.Session = await _request.Post <LocalCredentials, UserAndToken>(Path.Combine(_route, "login"), credentials); return(Parent.Session); }
public void SaveCurrentCredentials() { if (App.CurrentUserEnvironment == null || App.CurrentUserEnvironment.User == null) { return; } var credentials = new LocalCredentials() { Token = DataService.GeneratedToken, Email = App.CurrentUserEnvironment.User.Email, Password = App.CurrentUserEnvironment.User.Password }; var json = JsonConvert.SerializeObject(credentials); _saveDataService.SaveData(App.LocalCredentials, json); }
public async Task <UserAndToken> Login([FromBody] LocalCredentials credentials) { return(await _auth.IssueToken(credentials.Username, credentials.Password)); }
public async Task <bool> AutoConnect(string deviceModel , string platform , string version , string uniqueDeviceId , string countryCode) { // get connection information to auto connect LocalCredentials credentials = null; credentials = GetSavedCredentials(); if (credentials != null) { DataService.Email = credentials.Email; DataService.Pass = credentials.Password; DataService.GeneratedToken = credentials.Token; try { App.CurrentUserEnvironment = await _dataService.GetUserEnvironment(App.Locator.Login.VersionApplication, platform, deviceModel, version, uniqueDeviceId, countryCode); } catch (TimeoutException) { await _dialogService.ShowError( Resources.TimeoutError , Resources.TimeoutErrorTitle , Resources.Close, null); IsLoading = false; return(false); } catch (WebException) { await _dialogService.ShowError( Resources.TimeoutError , Resources.TimeoutErrorTitle , Resources.Close, null); IsLoading = false; return(false); } catch (Exception) { await _dialogService.ShowError( Resources.UnexpectedError , Resources.UnexpectedErrorTitle , Resources.Close, null); IsLoading = false; return(false); } if (App.CurrentUserEnvironment == null) { App.IsAppNeedUpdate = true; _navigationService.NavigateTo(App.NEED_UPDATE_PAGE); return(false); } else if (App.CurrentUserEnvironment.User == null) { return(false); } else { InitTimers(); // AppTimer is used for blocking notifications when the app is in background // It needs to be initialized when autoconnect and connect methods are called AppTimer = ServiceLocator.Current.GetInstance <ITimer>(); _navigationService.NavigateTo(App.LIST_SEEKIOS_PAGE); return(true); } } else { return(false); //else if (!string.IsNullOrEmpty(userEnvironment.User.SocialNetworkUserId)) //{ // var facebookEmail = userEnvironment.User.Email; // var facebookFirstName = userEnvironment.User.FirstName; // var facebookLastName = userEnvironment.User.LastName; // var facebookId = userEnvironment.User.SocialNetworkUserId; // var facebookPicture = userEnvironment.User.UserPicture; // connectOk = await ConnectWithFacebook(facebookEmail, facebookFirstName, facebookLastName, facebookId, facebookPicture, deviceModel, platform, version, uniqueDeviceId, countryCode, true); //} } }