/// <summary> /// </summary> /// <param name="userCredentials"> /// </param> /// <returns> /// </returns> public IObservable <UserLoginResponseContract> AuthenticateAsync(UserCredentialsContract userCredentials) { if (userCredentials == null || string.IsNullOrWhiteSpace(userCredentials.UserName) || string.IsNullOrWhiteSpace(userCredentials.Password)) { return(Observable.Empty <UserLoginResponseContract>()); } // downloader.UserCredentials = null; this.downloader.UserToken = null; string postData = string.Format( "login={0}&password={1}", ApiUrl.Escape(userCredentials.UserName), ApiUrl.Escape(userCredentials.Password)); IObservable <UserLoginResponseContract> userLogin = from response in this.downloader.PostAndGetStringAsync(ApiUrl.Authenticate(), postData) let user = Json <UserLoginResponseContract> .Instance.DeserializeFromString(response) where !string.IsNullOrWhiteSpace(user.UserToken) select user; return((from loginResponse in userLogin from _ in this.SaveCredentialsAsync(userCredentials) from __ in this.SaveUserTokenAsync(loginResponse) select loginResponse).Do( response => { PlayerService.DeletePlayToken(); this.downloader.UserToken = response.UserToken; // downloader.UserCredentials = userCredentials; })); }
/// <summary> /// </summary> /// <param name="creds"> /// </param> private void LoadCredentials(UserCredentialsContract creds) { if (creds == null) { return; } this.CanLogin = false; this.UserName = creds.UserName; this.Password = creds.Password; }
/// <summary> /// </summary> private void SignIn() { var creds = new UserCredentialsContract { UserName = this.UserName.Trim(), Password = this.Password }; this.CanLogin = false; this.ShowProgress(StringResources.Progress_SigningIn); this.AddToLifetime( this.profileService.AuthenticateAsync(creds).ObserveOnDispatcher().Subscribe( this.LoadLoginResponse, ex => { this.CanLogin = true; this.HandleError(ex); }, this.HideProgress)); }
/// <summary> /// </summary> /// <param name="userCredentials"> /// </param> /// <returns> /// </returns> private IObservable <PortableUnit> SaveCredentialsAsync(UserCredentialsContract userCredentials) { return(this.storage.SaveJsonAsync(CredentialsFilePath, userCredentials)); }
public ResultInfoContract SignIn(UserCredentialsContract credentials) { throw new NotImplementedException(); }