Esempio n. 1
0
 public static void Logout()
 {
     signingIn      = false;
     storedUsername = null;
     storedPassword = null;
     VRC.Tools.ClearCookies();
     APIUser.Logout();
     ApiCredentials.Clear();
     refreshWindow = true;
 }
Esempio n. 2
0
 // Token: 0x06005728 RID: 22312 RVA: 0x001E0636 File Offset: 0x001DEA36
 public new static void Logout()
 {
     if (APIUser.CurrentUser != null)
     {
         Analytics.Send(ApiAnalyticEvent.EventType.logout);
     }
     User.mCurrentNonApiUser = null;
     ApiCredentials.Clear();
     APIUser.Logout();
 }
Esempio n. 3
0
        private static void SignIn(bool explicitAttempt)
        {
            lock (syncObject)
            {
                if (signingIn ||
                    APIUser.IsLoggedInWithCredentials ||
                    (!explicitAttempt && string.IsNullOrEmpty(storedUsername)) ||
                    (!explicitAttempt && string.IsNullOrEmpty(storedPassword)))
                {
                    return;
                }

                signingIn = true;
            }

            Init();

            ApiCredentials.Clear();
            ApiCredentials.SetUser(username, password);
            APIUser.Login(
                delegate(APIUser user)
            {
                signingIn      = false;
                error          = null;
                storedUsername = username;
                storedPassword = password;
                AnalyticsSDK.LoggedInUserChanged(user);

                if (!APIUser.CurrentUser.canPublishAllContent)
                {
                    if (UnityEditor.SessionState.GetString("HasShownContentPublishPermissionsDialogForUser", "") != user.id)
                    {
                        UnityEditor.SessionState.SetString("HasShownContentPublishPermissionsDialogForUser", user.id);
                        VRC_SdkControlPanel.ShowContentPublishPermissionsDialog();
                    }
                }

                refreshWindow = true;
            },
                delegate(string message)
            {
                signingIn      = false;
                storedUsername = null;
                storedPassword = null;
                error          = message;
                VRC.Tools.ClearCookies();
                APIUser.Logout();
                refreshWindow = true;
                VRC.Core.Logger.Log("Error logging in: " + message);
            }
                );
        }
Esempio n. 4
0
        private void OnApplicationStart()
        {
            if (!ApiCredentials.Load())
            {
                VRCModLogger.Log("No credential founds");
            }
            else
            {
                VRCModLogger.Log("Credentials:\n - Token: " + ApiCredentials.GetAuthToken() + "\n - Provider: " + ApiCredentials.GetAuthTokenProvider() + "\n - UserId: " + ApiCredentials.GetAuthTokenProviderUserId());
            }


            String lp    = "";
            bool   first = true;

            foreach (var lp2 in Environment.GetCommandLineArgs())
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    lp += " " + lp2;
                }
            }
            VRCModLogger.Log("Launch parameters:" + lp);

            ModPrefs.RegisterCategory("vrctools", "VRCTools");
            ModPrefs.RegisterPrefBool("vrctools", "remoteauthcheckasked", false, null, true);
            ModPrefs.RegisterPrefBool("vrctools", "remoteauthcheck", false, "Allow VRCModNetwork Auth");
            ModPrefs.RegisterPrefBool("vrctools", "avatarfavdownloadasked", false, null, true);
            ModPrefs.RegisterPrefBool("vrctools", "avatarfavdownload", false, "Enable AvatarFav Updater");

            ModPrefs.RegisterPrefBool("vrctools", "enablediscordrichpresence", true, "Enable Discord RichPresence");
            ModPrefs.RegisterPrefBool("vrctools", "enabledebugconsole", false, "Enable Debug Console");

            ModPrefs.RegisterPrefBool("vrctools", "hasvrcmnwtoken", false, null, true);

            ModPrefs.RegisterPrefBool("vrctools", "allowdiscordjoinrequests", true, "Allow Discord join requests");

            //Reset the credentials to ask login again if this is the first time the user login to the VRCMNW
            if (!ModPrefs.GetBool("vrctools", "hasvrcmnwtoken"))
            {
                ApiCredentials.Clear();
            }
        }
Esempio n. 5
0
 // Token: 0x06005726 RID: 22310 RVA: 0x001E05B8 File Offset: 0x001DE9B8
 public static void SteamLogin(string authSessionTicket, Action <APIUser> onFetchSuccess = null, Action <string> onFetchError = null)
 {
     ApiCredentials.Clear();
     APIUser.ThirdPartyLogin("steam", new Dictionary <string, string>
     {
         {
             "steamTicket",
             authSessionTicket
         }
     }, delegate(string authToken, APIUser freshAPIUser)
     {
         ApiCredentials.SetAuthToken(authToken, "steam", SteamUser.GetSteamID().ToString());
         User.mCurrentNonApiUser = new User();
         User.mCurrentNonApiUser.Init(APIUser.CurrentUser);
         User.SetNetworkProperties();
         if (onFetchSuccess != null)
         {
             onFetchSuccess(freshAPIUser);
         }
     }, onFetchError);
 }
Esempio n. 6
0
        private static void SignIn(bool explicitAttempt)
        {
            lock (syncObject)
            {
                if (signingIn ||
                    APIUser.IsLoggedInWithCredentials ||
                    (!explicitAttempt && string.IsNullOrEmpty(storedUsername)) ||
                    (!explicitAttempt && string.IsNullOrEmpty(storedPassword)))
                {
                    return;
                }

                signingIn = true;
            }

            Init();

            ApiCredentials.Clear();
            ApiCredentials.SetUser(username, password);
            APIUser.Login(
                delegate(APIUser user)
            {
                signingIn      = false;
                error          = null;
                storedUsername = username;
                storedPassword = password;
                AnalyticsSDK.LoggedInUserChanged(user);
            },
                delegate(string message)
            {
                signingIn      = false;
                storedUsername = null;
                storedPassword = null;
                error          = message;
                APIUser.Logout();
                VRC.Core.Logger.Log("Error logging in: " + message);
            }
                );
        }
Esempio n. 7
0
        static bool OnAccountGUI()
        {
            EditorGUILayout.BeginVertical();

            EditorGUILayout.LabelField(Status);

            EditorGUILayout.Separator();
            EditorGUILayout.LabelField("Account", EditorStyles.boldLabel);

            if (signingIn)
            {
                EditorGUILayout.LabelField("Signing in.");
                EditorGUILayout.EndVertical();
                return(false);
            }
            else if (APIUser.IsLoggedInWithCredentials)
            {
                OnCreatorStatusGUI();

                if (GUILayout.Button("Logout"))
                {
                    storedUsername = username = null;
                    storedPassword = password = null;

                    ApiCredentials.Clear();
                    VRC.Tools.ClearCookies();
                    APIUser.Logout();
                    VRCContentManagerWindow.ClearContent();
                }
            }
            else
            {
                if (signingIn)
                {
                    EditorGUILayout.LabelField("Signing in.");
                }
                else
                {
                    Init();

                    username = EditorGUILayout.TextField("Username", username);
                    password = EditorGUILayout.PasswordField("Password", password);

                    if (GUILayout.Button("Sign In"))
                    {
                        SignIn(true);
                    }
                    if (GUILayout.Button("Sign up"))
                    {
                        Application.OpenURL("http://vrchat.com/register");
                    }
                }
            }

            {
                if (APIUser.CurrentUser == null || APIUser.CurrentUser.hasSuperPowers)
                {
                    EditorGUILayout.Separator();
                    EditorGUILayout.LabelField("API", EditorStyles.boldLabel);

                    ApiServerEnvironment newEnv = (ApiServerEnvironment)EditorGUILayout.EnumPopup("Use API", serverEnvironment);
                    if (serverEnvironment != newEnv)
                    {
                        serverEnvironment = newEnv;
                    }

                    if (APIUser.CurrentUser == null)
                    {
                        EditorGUILayout.EndVertical();
                        return(false);
                    }
                }
                else
                {
                    EditorGUILayout.Separator();
                    EditorGUILayout.LabelField("API", EditorStyles.boldLabel);

                    ApiServerEnvironment newEnv = (EditorGUILayout.Popup("Use API", serverEnvironment != ApiServerEnvironment.Beta ? 1 : 0, new string[] { "Beta", "Release" }) == 0 ? ApiServerEnvironment.Beta : ApiServerEnvironment.Release);
                    if (serverEnvironment != newEnv)
                    {
                        serverEnvironment = newEnv;
                    }
                }
            }

            // Future proof upload
            {
                EditorGUILayout.Separator();
                EditorGUILayout.LabelField("Publish", EditorStyles.boldLabel);
                bool futureProofPublish = UnityEditor.EditorPrefs.GetBool("futureProofPublish", DefaultFutureProofPublishEnabled);

                futureProofPublish = EditorGUILayout.Toggle("Future Proof Publish", futureProofPublish);

                if (UnityEditor.EditorPrefs.GetBool("futureProofPublish", DefaultFutureProofPublishEnabled) != futureProofPublish)
                {
                    UnityEditor.EditorPrefs.SetBool("futureProofPublish", futureProofPublish);
                }
            }

            if (APIUser.CurrentUser != null)
            {
                // custom vrchat install location
                OnVRCInstallPathGUI();
            }

            // debugging
            if (APIUser.CurrentUser != null && APIUser.CurrentUser.hasSuperPowers)
            {
                EditorGUILayout.Separator();
                EditorGUILayout.LabelField("Developer", EditorStyles.boldLabel);

                // API logging
                {
                    bool isLoggingEnabled = UnityEditor.EditorPrefs.GetBool("apiLoggingEnabled");
                    bool enableLogging    = EditorGUILayout.Toggle("API Logging Enabled", isLoggingEnabled);
                    if (enableLogging != isLoggingEnabled)
                    {
                        if (enableLogging)
                        {
                            VRC.Core.Logger.AddDebugLevel(DebugLevel.API);
                        }
                        else
                        {
                            VRC.Core.Logger.RemoveDebugLevel(DebugLevel.API);
                        }

                        UnityEditor.EditorPrefs.SetBool("apiLoggingEnabled", enableLogging);
                    }
                }

                // All logging
                {
                    bool isLoggingEnabled = UnityEditor.EditorPrefs.GetBool("allLoggingEnabled");
                    bool enableLogging    = EditorGUILayout.Toggle("All Logging Enabled", isLoggingEnabled);
                    if (enableLogging != isLoggingEnabled)
                    {
                        if (enableLogging)
                        {
                            VRC.Core.Logger.AddDebugLevel(DebugLevel.All);
                        }
                        else
                        {
                            VRC.Core.Logger.RemoveDebugLevel(DebugLevel.All);
                        }

                        UnityEditor.EditorPrefs.SetBool("allLoggingEnabled", enableLogging);
                    }
                }
            }
            else
            {
                if (UnityEditor.EditorPrefs.GetBool("apiLoggingEnabled"))
                {
                    UnityEditor.EditorPrefs.SetBool("apiLoggingEnabled", false);
                }
                if (UnityEditor.EditorPrefs.GetBool("allLoggingEnabled"))
                {
                    UnityEditor.EditorPrefs.SetBool("allLoggingEnabled", false);
                }
            }

            EditorGUILayout.EndVertical();

            return(true);
        }
Esempio n. 8
0
        private IEnumerator VRCToolsSetup()
        {
            initialising = true;
            VRCModLogger.Log("[VRCTools] Initialising VRCTools");
            try
            {
                OculusUtils.ApplyPatches();
            }
            catch (Exception e)
            {
                VRCModLogger.Log("[VRCTools] Error while applying Oculus patches: " + e);
            }
            yield return(VRCUiManagerUtils.WaitForUiManagerInit());

            VRCModLogger.Log("[VRCTools] Overwriting login button event");
            VRCUiPageAuthentication[] authpages = Resources.FindObjectsOfTypeAll <VRCUiPageAuthentication>();
            VRCUiPageAuthentication   loginPage = authpages.First((page) => page.gameObject.name == "LoginUserPass");

            if (loginPage != null)
            {
                Button loginButton = loginPage.transform.Find("ButtonDone (1)")?.GetComponent <Button>();
                if (loginButton != null)
                {
                    ButtonClickedEvent bce = loginButton.onClick;
                    loginButton.onClick = new ButtonClickedEvent();
                    loginButton.onClick.AddListener(() => {
                        VRCModNetworkManager.SetCredentials(GetTextFromUiInputField(loginPage.loginUserName) + ":" + GetTextFromUiInputField(loginPage.loginPassword));
                        bce?.Invoke();
                    });
                }
                else
                {
                    VRCModLogger.Log("[VRCTools] Unable to find login button in login page");
                }
            }
            else
            {
                VRCModLogger.Log("[VRCTools] Unable to find login page");
            }

            yield return(DependenciesDownloader.CheckDownloadFiles());

            yield return(VRCModLoaderUpdater.CheckVRCModLoaderHash());

            if (ModPrefs.GetBool("vrctools", "enablediscordrichpresence"))
            {
                DiscordManager.Init();
            }

            yield return(AvatarFavUpdater.CheckForAvatarFavUpdate());

            VRCModNetworkStatus.Setup();
            ModConfigPage.Setup();
            ModdedUsersManager.Init();

            /*
             * if (ApiCredentials.Load())
             * {
             *  VRCModLogger.Log("ApiCredentials.GetAuthTokenProviderUserId() => " + ApiCredentials.());
             *  if (!SecurePlayerPrefs.HasKey("vrcmnw_token_" + ApiCredentials.GetAuthTokenProviderUserId()))
             *  {
             *      ApiCredentials.Clear();
             *  }
             * }
             */
            ApiCredentials.Clear();


            VRCModLogger.Log("[VRCTools] Init done !");

            VRCUiPopupManagerUtils.GetVRCUiPopupManager().HideCurrentPopup();

            VRCFlowManagerUtils.EnableVRCFlowManager();

            initialising = false;
            Initialised  = true;

            VRCModNetworkManager.ConnectAsync();
        }