public IEnumerator OnNewGuest(VOGControllerAuth ctrl, AvatarGender gender) { try { ctrl.DisableInput(); //Create guest ApiCall call = VostopiaClient.Authentication.BeginSignInGuest(gender); IEnumerator e = call.Wait(); while (e.MoveNext()) { yield return e.Current; } if (!VostopiaClient.Authentication.EndSignIn(call)) { ctrl.ShowMessageDialog("Uh-oh", "There was an error creating a guest account for you. Please try again.", () => { }); yield break; } //Store authentication key if (call.ResponseData["authKey"] != null) { string authKey = (string)call.ResponseData["authKey"]; ctrl.StoreGuestAuthenticationKey(authKey); } //Continue to auth completed screen ctrl.AuthenticationCompleted(); } finally { ctrl.EnableInput(); } }
public IEnumerator OnNewUser(VOGControllerAuth ctrl, AvatarGender gender) { try { ctrl.DisableInput(); //Create user ApiCall call = VostopiaClient.Authentication.BeginRegister(Email, KeepInTouch, gender); IEnumerator e = call.Wait(); while (e.MoveNext()) { yield return e.Current; } var registerResult = VostopiaClient.Authentication.EndRegister(call); if (registerResult != VostopiaAuthenticationClient.RegisterResult.SUCCESS) { Debug.LogWarning("Error creating new user, " + registerResult); string msg = ""; if (registerResult == VostopiaAuthenticationClient.RegisterResult.USER_ALREADY_EXISTS) { msg = "That email address is already in use! Please try another."; } else if (registerResult == VostopiaAuthenticationClient.RegisterResult.INVALID_EMAIL) { msg = "That email address doesn't make sense to us =( Please try again."; } else { msg = "Something went wrong while creating your account =( Please try again."; } //Show message box and return to previous screen ctrl.ShowMessageDialog("Uh-oh", msg, () => { ctrl.StartBackTransition(); }); yield break; } //Store authentication key if (call.ResponseData["authKey"] != null) { string authKey = (string)call.ResponseData["authKey"]; ctrl.StoreGuestAuthenticationKey(authKey); } //Continue to auth completed screen ctrl.AuthenticationCompleted(); } finally { ctrl.EnableInput(); } }
public IEnumerator OnAuthenticate(VOGControllerAuth ctrl) { try { ctrl.DisableInput(); if (CurrentPasswordData == null || CurrentPasswordData.User == null) { ctrl.ShowMessageDialog("Doh!", "An error occurred during authentication. Please try again", () => { }); yield break; } VostopiaUser user = CurrentPasswordData.User; //Try to authenticate user ApiCall call = VostopiaClient.Authentication.BeginSignIn(user.Username, Password, true); IEnumerator e = call.Wait(); while (e.MoveNext()) { yield return e.Current; } if (!VostopiaClient.Authentication.EndSignIn(call)) { ctrl.ShowMessageDialog("Uh-oh", "The password you entered doesn't match our records. Please try again or use the 'Send me a new password' option below.", () => { }); yield break; } //Store authentication key if (call.ResponseData["authKey"] != null) { ctrl.StoreUserAuthenticationKey(user, (string)call.ResponseData["authKey"]); } ctrl.AuthenticationCompleted(); } finally { ctrl.EnableInput(); } }
public IEnumerator OnSignIn(VOGControllerAuth ctrl) { try { ctrl.DisableInput(); var authSelectData = new VOGStateAuthSelect.AuthSelectData(); authSelectData.EnableCancel = false; //Make sure we have UserAuth object if (UserAuth == null || string.IsNullOrEmpty(UserAuth.AuthKey)) { ctrl.ShowMessageDialog("Doh!", "An error occurred during authentication. Please try again", () => { ctrl.StartTransition(AuthSelectorScreen, authSelectData); }); yield break; } //Try to authenticate user ApiCall call = VostopiaClient.Authentication.BeginSignInAuthKey(UserAuth.AuthKey); IEnumerator e = call.Wait(); while (e.MoveNext()) { yield return e.Current; } if (!VostopiaClient.Authentication.EndSignIn(call)) { ctrl.ShowMessageDialog("Session Expired", "Your authentication session has expired. Please sign in again.", () => { ctrl.StartTransition(AuthSelectorScreen, authSelectData); }); yield break; } //Continue to auth completed screen ctrl.AuthenticationCompleted(); } finally { ctrl.EnableInput(); } }
/** * Sign in as guest. If a guest authkey is found in playerprefs, use that to log in as the same guest. * If no guest authkey is found, show the sign in as guest screen, where the user gets to select a gender. */ public IEnumerator OnSignInGuest(VOGControllerAuth ctrl) { try { ctrl.DisableInput(); //Try to authenticate as the same guest as last time (if there's a last time) string authKey = ctrl.GetStoredGuestAuthenticationKey(); //Don't use saved guest account if ctrl is pressed while clicking on the button if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) { authKey = null; } bool completed = false; if (!string.IsNullOrEmpty(authKey)) { ApiCall call = VostopiaClient.Authentication.BeginSignInAuthKey(authKey); IEnumerator e = call.Wait(); while (e.MoveNext()) { yield return e.Current; } if (VostopiaClient.Authentication.EndSignIn(call)) { //Complete auth ctrl.AuthenticationCompleted(); completed = true; } } //otherwise, send on to gender select screen if (!completed) { ctrl.StartTransition(GuestState); } } finally { ctrl.EnableInput(); } }