/// <summary> /// Used for initially Creating an anonymous account /// </summary> /// <param name="users_name">The display name of the user</param> /// <returns></returns> private IEnumerator Acquire_Anonymous_Tokens(string users_name) { YUR_Log.Log("Beginning to Login as an Anonymous User"); string response; yield return(response = Systems.Interops.User_AccountCreation.CreateAnonymousAccount()); if (response.StartsWith("--1")) { Bad_Login?.Invoke(response); yield break; } YUR_Log.Log("Successfully authenticated, begin retrieving data!"); yield return(CurrentUser.loginCredentials = Utilities.YUR_Conversions.ConvertStringToObject <LoginCredentials> (response)); YUR_Log.Log("Test"); YUR_Log.Log("ActiveUserAccount : " + CurrentUser.loginCredentials.RefreshToken); yield return(StartCoroutine(Get_UserData())); yield return(YUR_Main.main.User_Manager.CurrentUser.Data_Biometrics.Name = users_name); yield return(YUR_CurrentUser.Store_RefreshToken(CurrentUser.Data_Biometrics.Name, CurrentUser.Profile.PhotoURL, CurrentUser.loginCredentials.RefreshToken)); Successful_Login?.Invoke("Successfull Login!"); yield break; }
/// <summary> /// Used for initial login. Gets required login and persitence tokens /// </summary> /// <param name="email"></param> /// <param name="password"></param> /// <returns></returns> private IEnumerator Acquire_Access_Tokens(string email, string password) { YUR_Log.Log("Logging in with Email and Password"); string response; yield return(response = Systems.Interops.User_AccountAuthorization.Login_User(email, password)); YUR_Log.Log("Received data from Native DLL: " + response); if (response.StartsWith("--1")) { string error = "Login Credentials are invalid"; if (response.Contains("EMAIL_NOT_FOUND")) { error = "Email does not exist, try again"; } Bad_Login?.Invoke(error); yield break; } YUR_Log.Log("Successfully authenticated, begin retrieving data!"); YUR_Log.Server_Log("Received Data: " + response); yield return(CurrentUser.loginCredentials = Utilities.YUR_Conversions.ConvertStringToObject <LoginCredentials>(response)); YUR_Log.Log("Test"); YUR_Log.Log("ActiveUserAccount : " + CurrentUser.loginCredentials.RefreshToken); yield return(StartCoroutine(Get_UserData())); YUR_Log.Log("ActiveUserAccount Refresh Token: " + CurrentUser.loginCredentials.RefreshToken); YUR_Log.Log("ActiveUser PhotoURL: " + CurrentUser.Profile.PhotoURL); YUR_Log.Log("ActiveUserAccount DisplayName: " + CurrentUser.loginCredentials.DisplayName); yield return(YUR_CurrentUser.Store_RefreshToken(CurrentUser.loginCredentials.DisplayName, CurrentUser.Profile.PhotoURL, CurrentUser.loginCredentials.RefreshToken)); Successful_Login?.Invoke("Successfull Login!"); yield break; }
void Awake() { YUR_Users = this; DontDestroyOnLoad(this); DontDestroyOnLoad(YUR_Users); CurrentUser = new YUR_CurrentUser(); CurrentUser = gameObject.AddComponent <YUR_CurrentUser>(); Successful_Login += Users_Successful_Login; Bad_Login += Users_Bad_Login; Logging_In += Users_Logging_In; }
public void OnEnable() { UserCount = YUR_Main.main.UserList.Count; UsersNames = new string[UserCount]; for (int i = 0; i < UserCount; i++) { if (YUR_Main.main.UserList[i] == YUR_Main.main.User_Manager.CurrentUser.loginCredentials.LocalId) { UserIndex = i; } } if (Login.Status == Login.StatusType.Logged_In) { ProfileName.text = YUR_Main.main.User_Manager.CurrentUser.Data_Biometrics.Name; /// Get User picture here /// UsersNames[UserIndex] = YUR_Main.main.User_Manager.CurrentUser.Data_Biometrics.Name; } else { UserIndex = 0; YUR_CurrentUser.Local_User_Info_Reference Reference = YUR_CurrentUser.Preview_User(YUR_Main.main.UserList[UserIndex]); ProfileName.text = Reference.name; UsersNames[UserIndex] = Reference.name; } NewSignIn.onClick.AddListener(delegate { Logout.ActiveUser("Logging out from switch user screen"); YURScreenCoordinator.ScreenCoordinator.PresentNewScreen(Screens_InitialLogin.inst, true); }); SignInUser.onClick.AddListener(delegate { if (YUR_Main.main.UserList[UserIndex] == YUR_Main.main.User_Manager.CurrentUser.loginCredentials.LocalId) { YURScreenCoordinator.ScreenCoordinator.PresentNewScreen(Screens_MainMenu.inst, true); } else { UserManagement.YUR_UserManager.Successful_Login += YUR_UserManager_Successful_Login; UserManagement.YUR_UserManager.Bad_Login += YUR_UserManager_Bad_Login; Login.User_ID(YUR_Main.main.UserList[UserIndex]); } }); Next.onClick.AddListener(delegate { if (UserIndex + 1 > UserCount - 1) { UserIndex = 0; } else { UserIndex++; } if (!string.IsNullOrEmpty(UsersNames[UserIndex])) { ProfileName.text = UsersNames[UserIndex]; } else { YUR_CurrentUser.Local_User_Info_Reference Reference = YUR_CurrentUser.Preview_User(YUR_Main.main.UserList[UserIndex]); ProfileName.text = Reference.name; UsersNames[UserIndex] = Reference.name; } /// Get User Profile Picture }); Prev.onClick.AddListener(delegate { if (UserIndex - 1 < 0) { UserIndex = UserCount - 1; } else { UserIndex--; } if (!string.IsNullOrEmpty(UsersNames[UserIndex])) { ProfileName.text = UsersNames[UserIndex]; } else { YUR_CurrentUser.Local_User_Info_Reference Reference = YUR_CurrentUser.Preview_User(YUR_Main.main.UserList[UserIndex]); ProfileName.text = Reference.name; UsersNames[UserIndex] = Reference.name; } }); }
IEnumerator Setup() { YUR_Log.Log("Setting up Profile"); yield return(User = UserManagement.YUR_UserManager.YUR_Users.CurrentUser); YUR_Log.Log("Retrieved the user manager"); Title.text = User.Data_Biometrics.Name + "'s Profile"; UpdateAge(); /// BirthDate //////////////////////////////////// BirthDate.Day.PlaceHolder.text = "Day"; BirthDate.Day.gameObject.GetComponent <VRUiKits.Utils.UIKitInputField>().text = User.Data_Biometrics.BirthDate[2]; BirthDate.Month.PlaceHolder.text = "Month"; BirthDate.Month.gameObject.GetComponent <VRUiKits.Utils.UIKitInputField>().text = User.Data_Biometrics.BirthDate[1]; BirthDate.Year.PlaceHolder.text = "Year"; BirthDate.Year.gameObject.GetComponent <VRUiKits.Utils.UIKitInputField>().text = User.Data_Biometrics.BirthDate[0]; /// Units //////////////////////////////////// if (User.Data_Biometrics.Metric_Units) { Units.selectedValue = "Metric"; /// Weight Weight.PlaceHolder.text = "kgs"; Weight.gameObject.GetComponent <VRUiKits.Utils.UIKitInputField>().text = User.Data_Biometrics.metric.Weight.ToString(); Weight.Label.text = "Weight: (in kilograms)"; /// Height Height.PlaceHolder.text = "cm"; Height.gameObject.GetComponent <VRUiKits.Utils.UIKitInputField>().text = (User.Data_Biometrics.metric.Height * 100).ToString(); Height.Label.text = "Height: (in centimeters)"; } else { Units.selectedValue = "Customary"; /// Weight Weight.PlaceHolder.text = "lbs"; Weight.gameObject.GetComponent <VRUiKits.Utils.UIKitInputField>().text = User.Data_Biometrics.customary.Weight.ToString(); Weight.Label.text = "Weight: (in pounds)"; /// Height Height.PlaceHolder.text = "in"; Height.gameObject.GetComponent <VRUiKits.Utils.UIKitInputField>().text = User.Data_Biometrics.customary.Height.ToString(); Height.Label.text = "Height: (in inches)"; } /// Sex /////////////////////////////////////// if (User.Data_Biometrics.Sex == "male") { Sex.selectedValue = "Male"; } else if (User.Data_Biometrics.Sex == "female") { Sex.selectedValue = "Female"; } else { Sex.selectedValue = "Unspecified"; } Units.NextPressed += Units_PrevPressed; Units.PrevPressed += Units_PrevPressed; Sex.NextPressed += Sex_NextPressed; Sex.PrevPressed += Sex_PrevPressed; YURScreenCoordinator.ScreenCoordinator.Keyboard.SetActive(true, KeyboardCanvas.KeyboardStyle.KeyboardNumPad); yield break; }