public void LogOutAction() { ParseUser.LogOutAsync(); _loginPanel.GetComponent <LoginManager>().Show(); gameObject.SetActive(false); }
public Task TestLogOut() { IObjectState state = new MutableObjectState { ServerData = new Dictionary <string, object>() { { "sessionToken", "r:llaKcolnu" } } }; ParseUser user = ParseObjectExtensions.FromState <ParseUser>(state, "_User"); var mockCurrentUserController = new Mock <IParseCurrentUserController>(); mockCurrentUserController.Setup(obj => obj.GetAsync(It.IsAny <CancellationToken>())) .Returns(Task.FromResult(user)); var mockSessionController = new Mock <IParseSessionController>(); mockSessionController.Setup(c => c.IsRevocableSessionToken(It.IsAny <string>())).Returns(true); ParseCorePlugins.Instance = new ParseCorePlugins { CurrentUserController = mockCurrentUserController.Object, SessionController = mockSessionController.Object }; ParseObject.RegisterSubclass <ParseUser>(); ParseObject.RegisterSubclass <ParseSession>(); return(ParseUser.LogOutAsync().ContinueWith(t => { Assert.False(t.IsFaulted); Assert.False(t.IsCanceled); mockCurrentUserController.Verify(obj => obj.LogOutAsync(It.IsAny <CancellationToken>()), Times.Exactly(1)); mockSessionController.Verify(obj => obj.RevokeAsync("r:llaKcolnu", It.IsAny <CancellationToken>()), Times.Exactly(1)); })); }
public void Logout() { if (ParseUser.CurrentUser != null) { ParseUser.LogOutAsync(); } }
public void LogOut() { // disable loginPanel and user buttons loginPanel.setMode(LoginPanel.Mode.LOADING); GameObject loginPanelObject = loginPanel.gameObject; enableUserButtons(false); AddLog("Logging Out \n--------------"); ParseUser.LogOutAsync().ContinueWith(t => { // check for errors if (t.IsFaulted) { Exception ex = t.Exception; bufferedLog.Push(ex.ToString()); } else if (t.IsCanceled) { bufferedLog.Push("operation cancelled"); } else { bufferedLog.Push("[User logged out]"); } objectsToEnable.Push(loginPanelObject); }); }
public void LogOutUser() { if (ParseUser.CurrentUser != null) { ParseUser.LogOutAsync(); } GuiManager.Instance.ShowLoginPage(); }
public async Task LogoutAsync() { try { await ParseUser.LogOutAsync(); } catch (Exception e) { Console.Error.WriteLine(@" ERROR {0}", e.Message); } }
partial void BtnLogout_TouchUpInside(UIButton sender) { //Parse.ParseUser.LogOut(); ParseUser.LogOutAsync(); var home = Storyboard.InstantiateViewController("Home") as ViewController; NavigationController.PushViewController(home, true); }
/* * Logt einen User aus in der Datenbank. */ public void signOut() { if (ParseUser.CurrentUser != null) { ParseUser.LogOutAsync(); } else { Debug.Log("Ausloggen nicht erfolgreich."); } }
IEnumerator UpdateUser() { LoadAlert.Instance.StartLoad("Updating User Account...", null, -1); ParseUser.CurrentUser.Password = PasswordField.text; User.CurrentUser.Name = NameField.text; Task task = ParseUser.CurrentUser.SaveAsync(); while (!task.IsCompleted) { yield return(null); } if (task.IsFaulted) { LoadAlert.Instance.Done(); Debug.Log("couldn't update information:\n" + task.Exception.ToString()); } else { string email = ParseUser.CurrentUser.Email; Task logout = ParseUser.LogOutAsync(); while (!logout.IsCompleted) { yield return(null); } if (logout.IsFaulted) { } else { Task login = ParseUser.LogInAsync(email, PasswordField.text); while (!login.IsCompleted) { yield return(null); } if (login.IsFaulted) { } else { LoadAlert.Instance.Done(); PasswordField.text = ConfirmField.text = NameField.text = ""; Deactivate(); } } } }
public async Task LogOut() { await DisconnectUserFromInstallation(); await ParseUser.LogOutAsync() .ContinueWith(t => { if (t.IsFaulted) { t.Exception.Handle(ex => true); //ParseErrorHandler.HandleParseError(t.Exception.InnerException as ParseException); } _notificationCenter.Send(NotificationKeys.CurrentUserChanged, _currentUser); }); }
IEnumerator LogoutCoroutine() { LoadAlert.Instance.StartLoad("Logging out...", null, -1); Task task = ParseUser.LogOutAsync(); while (!task.IsCompleted) { yield return(null); } LoadAlert.Instance.Done(); if (task.IsFaulted) { Debug.Log("failed to logout:\n" + task.Exception.ToString()); } else { ClientList.ClearElements(); (OveriddenNavigation.Instance as OveriddenNavigation).PopToLogin(); } }
public static async Task <int> SignOut() { await ParseUser.LogOutAsync(); return(1); }
public void QuitLogin() { SceneManager.LoadScene("UIScene"); ParseUser.LogOutAsync(); }
public void Start() { // update user parse task UpdateCommand.Subscribe( _ => { ParseUser user = ParseUser.CurrentUser; String oldUsername = user.Username; String oldEmail = user.Email; String newUsername = ProfileUsername.Value; String newPassword = ProfilePassword.Value; String newEmail = ProfileEmail.Value; if (newUsername != "") { user.Username = newUsername; } if (newPassword != "") { user.Password = newPassword; } if (newEmail != "") { user.Email = newEmail; } AsyncSubject <Task> asyncSubject = new AsyncSubject <Task>(); user.SaveAsync().ContinueWith( x => { bool updateSuccessful = false; if (x.IsFaulted) { LogParseError(x.Exception); asyncSubject.OnError(x.Exception); } if (x.IsCompleted && !x.IsCanceled) { if (!x.IsFaulted) { UserData.OnNext(ParseUser.CurrentUser); updateSuccessful = true; } asyncSubject.OnNext(x); asyncSubject.OnCompleted(); } if (x.IsCanceled) { asyncSubject.OnError(new OperationCanceledException()); // was TaskCanceledException(x)) } if (!updateSuccessful) { user.Username = oldUsername; user.Email = oldEmail; asyncSubject.OnCompleted(); } }); return (UniRx.Observable.AsUnitObservable(asyncSubject).ObserveOnMainThread()); }); // login parse task LoginCommand.Subscribe( _ => { var parseLoginStream = TaskObservableExtensions.ToObservable( ParseUser.LogInAsync(LoginUsername.Value, LoginPassword.Value)); parseLoginStream.Subscribe( pu => { UserData.OnNext(pu); }, error => { LogParseError(error); } ); return (UniRx.Observable.AsUnitObservable(parseLoginStream).ObserveOnMainThread()); }); // logout task LogoutCommand.Subscribe( _ => { AsyncSubject <Task> asyncSubject = new AsyncSubject <Task>(); ParseUser.LogOutAsync().ContinueWith( x => { if (x.IsFaulted) { LogParseError(x.Exception); asyncSubject.OnError(x.Exception); } if (x.IsCompleted && !x.IsCanceled) { if (!x.IsFaulted) { UserData.OnNext(ParseUser.CurrentUser); } asyncSubject.OnNext(x); asyncSubject.OnCompleted(); } if (x.IsCanceled) { asyncSubject.OnError(new OperationCanceledException()); // was TaskCanceledException(x)) } }); return(UniRx.Observable.AsUnitObservable(asyncSubject).ObserveOnMainThread()); }); // signup parse task SignupCommand.Subscribe( _ => { ParseUser newUser = new ParseUser(); newUser.Username = LoginUsername.Value; newUser.Password = LoginPassword.Value; AsyncSubject <Task> asyncSubject = new AsyncSubject <Task>(); newUser.SignUpAsync().ContinueWith( x => { if (x.IsFaulted) { LogParseError(x.Exception); asyncSubject.OnError(x.Exception); } if (x.IsCompleted && !x.IsCanceled) { if (!x.IsFaulted) { UserData.OnNext(ParseUser.CurrentUser); } asyncSubject.OnNext(x); asyncSubject.OnCompleted(); } if (x.IsCanceled) { asyncSubject.OnError(new OperationCanceledException()); // was TaskCanceledException(x)) } }); return(UniRx.Observable.AsUnitObservable(asyncSubject).ObserveOnMainThread()); }); // Facebook login task FBLoginCommand.Subscribe( _ => { // we cascade this asyncSubject through 3 steps: fblogin, parseuserlogin, and parse fb id update AsyncSubject <FacebookDelegate <ILoginResult> > asyncSubject = new AsyncSubject <FacebookDelegate <ILoginResult> >(); FacebookDelegate <ILoginResult> handleFBLoginResult = result => { bool additionalOperation = false; if (result == null) { Debug.Log("Null Response from FB Login"); } // Some platforms return the empty string instead of null. if (!string.IsNullOrEmpty(result.Error)) { Debug.Log("Error Response:\n" + result.Error); } else if (result.Cancelled) { Debug.Log("Cancelled Response:\n" + result.RawResult); } else if (!string.IsNullOrEmpty(result.RawResult)) { additionalOperation = true; Debug.Log("Success Response:\n" + result.RawResult); AccessToken uat = AccessToken.CurrentAccessToken; Debug.Log("FB User Id: " + uat.UserId); var parseLoginStream = TaskObservableExtensions.ToObservable( ParseFacebookUtils.LogInAsync(uat.UserId, uat.TokenString, uat.ExpirationTime)); parseLoginStream.Subscribe( pu => { // if the user doesn't have an fbId field, we do another parse update call to add fbId field if (!pu.ContainsKey(KEY_FBID)) { Debug.Log("no fbId found: updating user"); pu["fbId"] = uat.UserId; pu.SaveAsync().ContinueWith(t => { if (t.IsFaulted) { Exception ex = t.Exception; LogParseError(ex); asyncSubject.OnError(ex); } else if (t.IsCanceled) { Debug.Log("user update cancelled"); } else { Debug.Log("[User " + pu.Username + " updated] id = " + pu.ObjectId); UserData.OnNext(pu); } asyncSubject.OnCompleted(); }); } else { UserData.OnNext(pu); asyncSubject.OnCompleted(); } }, error => { LogParseError(error); asyncSubject.OnError(error); } ); } else { Debug.Log("Empty Response\n"); } if (!additionalOperation) { asyncSubject.OnCompleted(); } }; FB.LogInWithReadPermissions(new List <string>() { "public_profile", "email", "user_friends" }, handleFBLoginResult); return(UniRx.Observable.AsUnitObservable(asyncSubject).ObserveOnMainThread()); }); // facebook link FBLinkCommand.Subscribe( _ => { ParseUser user = ParseUser.CurrentUser; // user is already linked to FB if (ParseFacebookUtils.IsLinked(user)) { AsyncSubject <Task> asyncSubject = new AsyncSubject <Task>(); ParseFacebookUtils.UnlinkAsync(user).ContinueWith(t => { // check for errors if (t.IsFaulted) { LogParseError(t.Exception); asyncSubject.OnError(t.Exception); } else if (t.IsCanceled) { Debug.Log("operation cancelled"); } else { Debug.Log("[User " + user.Username + " FB unlinked]"); user.Remove("fbId"); // user unlinked, now update parse user user.SaveAsync().ContinueWith( x => { if (x.IsFaulted) { LogParseError(x.Exception); asyncSubject.OnError(x.Exception); } if (x.IsCompleted && !x.IsCanceled) { if (!x.IsFaulted) { UserData.OnNext(ParseUser.CurrentUser); } asyncSubject.OnNext(x); asyncSubject.OnCompleted(); } if (x.IsCanceled) { asyncSubject.OnError(new OperationCanceledException()); // was TaskCanceledException(x)) } }); } }); return (UniRx.Observable.AsUnitObservable(asyncSubject).ObserveOnMainThread()); } // user has not linked yet else { // we cascade this asyncSubject through 3 steps: fblogin, parseuserlink, and parse fb id update AsyncSubject <FacebookDelegate <ILoginResult> > asyncSubject = new AsyncSubject <FacebookDelegate <ILoginResult> >(); FacebookDelegate <ILoginResult> handleFBLoginResult = result => { bool additionalOperation = false; if (result == null) { Debug.Log("Null Response from FB Login"); } // Some platforms return the empty string instead of null. if (!string.IsNullOrEmpty(result.Error)) { Debug.Log("Error Response:\n" + result.Error); } else if (result.Cancelled) { Debug.Log("Cancelled Response:\n" + result.RawResult); } else if (!string.IsNullOrEmpty(result.RawResult)) { additionalOperation = true; Debug.Log("Success Response:\n" + result.RawResult); AccessToken uat = AccessToken.CurrentAccessToken; Debug.Log("FB User Id: " + uat.UserId); ParseFacebookUtils.LinkAsync(user, uat.UserId, uat.TokenString, uat.ExpirationTime) .ContinueWith( t => { if (t.IsFaulted) { Exception ex = t.Exception; LogParseError(ex); asyncSubject.OnError(ex); } else if (t.IsCanceled) { Debug.Log("user update cancelled"); } else { // link success, now we add the fb field to user user["fbId"] = uat.UserId; user.SaveAsync().ContinueWith( t2 => { if (t2.IsFaulted) { Exception ex = t2.Exception; LogParseError(ex); asyncSubject.OnError(ex); } else if (t2.IsCanceled) { Debug.Log("user update cancelled"); } else { Debug.Log("[User " + user.Username + " updated] id = " + user.ObjectId); UserData.OnNext(user); } asyncSubject.OnCompleted(); }); } } ); } else { Debug.Log("Empty Response\n"); } if (!additionalOperation) { asyncSubject.OnCompleted(); } }; FB.LogInWithReadPermissions(new List <string>() { "public_profile", "email", "user_friends" }, handleFBLoginResult); return (UniRx.Observable.AsUnitObservable(asyncSubject).ObserveOnMainThread()); } }); // check if user logged in UserData.OnNext(ParseUser.CurrentUser); }