/// <summary>
        /// Login user by their userUID. User must be stored locally
        /// </summary>
        /// <param name="userUID">Unique identifier for users</param>
        /// <returns>String displaying login info</returns>
        internal string Login_USERID(string userUID)
        {
            try
            {
                Logging_In?.Invoke("Login using a USER ID Invoked");
                YUR_Log.Server_Log("Retrieving locally stored Refresh token");
                var combine   = Utilities.YUR_Conversions.PathCombine(Application.persistentDataPath, YUR_Constants.USERS_FILEPATH);
                var usersPath = Utilities.YUR_Conversions.PathCombine(combine, userUID + ".json");
                YUR_Log.Log("User Found at: " + usersPath);
                var userRefresh = System.IO.File.ReadAllText(usersPath);

                YUR_Log.Log("File contents: " + userRefresh);
                YUR_CurrentUser.Local_User_Info_Reference tmp = new YUR_CurrentUser.Local_User_Info_Reference();
                tmp = Utilities.YUR_Conversions.ConvertStringToObject <YUR_CurrentUser.Local_User_Info_Reference>(userRefresh);
                YUR_Log.Log("Refresh Token: " + tmp.refresh_token);
                YUR_Log.Server_Log("Refresh token acquired, passing to Native DLL");

                StartCoroutine(Get_IDtoken(tmp.refresh_token));
            }
            catch (System.Exception e)
            {
                YUR_Log.Error("Login with Refresh Token Error: " + e);
            }
            YUR_Log.Server_Log("Waiting for response from server");
            return("Logging in User");
        }
Example #2
0
        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;
                }
            });
        }