/// <summary> /// Obtains required login credentials using a valid refreshtoken and then updates all of the users login details /// </summary> /// <param name="refreshToken">Valid refresh token retrieved from initial login</param> /// <returns></returns> private IEnumerator Get_IDtoken(string refreshToken) { YUR_Log.Log("Getting Login Token with Refresh Token"); string refreshResponse; refreshResponse = Systems.Interops.User_AccountAuthorization.Retrieve_IDToken(refreshToken); if (refreshResponse.StartsWith("--1")) { Bad_Login?.Invoke(refreshResponse); yield break; } if (!CurrentUser.Convert_Refresh_Login(refreshResponse)) { YUR_Log.Error("Get IDToken could not use Convert Refresh Login Method. Login was unnsuccessful."); Login.status = Login.StatusType.Logging_Out; Logout.ActiveUser(); yield break; } yield return(StartCoroutine(Get_UserData())); Successful_Login?.Invoke("Successfull Login!"); yield break; }
/// <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; }
/// <summary> /// Updates specified data from database /// </summary> /// <param name="dataType"></param> /// <returns></returns> internal IEnumerator Refresh_Token_Set_Data(YUR_CurrentUser.DataType dataType) { string refreshResponse; yield return(refreshResponse = Systems.Interops.User_AccountAuthorization.Retrieve_IDToken(CurrentUser.loginCredentials.IDtoken)); if (refreshResponse.StartsWith("--1")) { Bad_Login?.Invoke(refreshResponse); yield break; } YUR_Log.Log("Refresh token worked! Setting all other data"); yield return(CurrentUser.Convert_Refresh_Login(refreshResponse)); StartCoroutine(Set_UserData(dataType)); yield break; }
/// <summary> /// Used for Creating a new account. Creates an account and then signs the user in. /// </summary> /// <param name="email"></param> /// <param name="password"></param> /// <param name="displayName"></param> /// <returns></returns> private IEnumerator Create_New_Account_Email_Password(string email, string password, string displayName) { YUR_Log.Server_Log("Creating an account with Email and Password"); string response; yield return(response = Systems.Interops.User_AccountCreation.CreateAccount(email, password, displayName)); if (response.StartsWith("--1")) { Bad_Login?.Invoke("Account Creation Failed: " + response); yield break; } YUR_Log.Server_Log("Account creation was successful, waiting for profile to build"); yield return(new WaitForSeconds(3)); Logging_In?.Invoke("Attempting to Login to account"); yield return(StartCoroutine(Acquire_Access_Tokens(email, password))); yield break; }