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(); } }