Ejemplo n.º 1
0
        public static void Init()
        {
            if (isInitialized)
            {
                return;
            }

            // make sure the api url is set correctly before attempting to log in
            RefreshApiUrlSetting();

            if (!APIUser.IsLoggedInWithCredentials && ApiCredentials.Load())
            {
                APIUser.FetchCurrentUser((c) => AnalyticsSDK.LoggedInUserChanged(c.Model as APIUser), null);
            }

            clientInstallPath = SDKClientUtilities.GetSavedVRCInstallPath();
            if (string.IsNullOrEmpty(clientInstallPath))
            {
                clientInstallPath = SDKClientUtilities.LoadRegistryVRCInstallPath();
            }

            signingIn     = false;
            isInitialized = true;

            VRCContentManagerWindow.ClearContent();
        }
Ejemplo n.º 2
0
        public static void Init()
        {
            if (!RemoteConfig.IsInitialized())
            {
                RemoteConfig.Init();
            }

            if (isInitialized)
            {
                return;
            }

            if (!APIUser.IsLoggedInWithCredentials && ApiCredentials.Load())
            {
                APIUser.Login((user) => AnalyticsSDK.LoggedInUserChanged(user), null);
            }

            clientInstallPath = SDKClientUtilities.GetSavedVRCInstallPath();
            if (string.IsNullOrEmpty(clientInstallPath))
            {
                clientInstallPath = SDKClientUtilities.LoadRegistryVRCInstallPath();
            }

            signingIn     = false;
            isInitialized = true;
        }
        private static void SignIn(bool explicitAttempt)
        {
            lock (syncObject)
            {
                if (signingIn ||
                    APIUser.IsLoggedInWithCredentials ||
                    (!explicitAttempt && string.IsNullOrEmpty(storedUsername)) ||
                    (!explicitAttempt && string.IsNullOrEmpty(storedPassword)))
                {
                    return;
                }

                signingIn = true;
            }

            Init();

            APIUser.Login(username, password,
                          delegate(ApiModelContainer <APIUser> c)
            {
                APIUser user = c.Model as APIUser;
                if (c.Cookies.ContainsKey("auth"))
                {
                    ApiCredentials.Set(user.username, username, "vrchat", c.Cookies["auth"]);
                }
                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(ApiModelContainer <APIUser> c)
            {
                signingIn      = false;
                storedUsername = null;
                storedPassword = null;
                error          = c.Error;
                VRC.Tools.ClearCookies();
                APIUser.Logout();
                refreshWindow = true;
                VRC.Core.Logger.Log("Error logging in: " + error);
            }
                          );
        }
Ejemplo n.º 4
0
    private static void AttemptLogin()
    {
        APIUser.Login(username, password,
                      delegate(ApiModelContainer <APIUser> c)
        {
            APIUser user = c.Model as APIUser;
            if (c.Cookies.ContainsKey("twoFactorAuth"))
            {
                ApiCredentials.Set(user.username, username, "vrchat", c.Cookies["auth"], c.Cookies["twoFactorAuth"]);
            }
            else if (c.Cookies.ContainsKey("auth"))
            {
                ApiCredentials.Set(user.username, username, "vrchat", c.Cookies["auth"]);
            }
            else
            {
                ApiCredentials.SetHumanName(user.username);
            }
            signingIn      = false;
            error          = null;
            storedUsername = null;
            storedPassword = null;
            AnalyticsSDK.LoggedInUserChanged(user);

            if (!APIUser.CurrentUser.canPublishAllContent)
            {
                if (UnityEditor.SessionState.GetString("HasShownContentPublishPermissionsDialogForUser", "") != user.id)
                {
                    UnityEditor.SessionState.SetString("HasShownContentPublishPermissionsDialogForUser", user.id);
                    VRCSdkControlPanel.ShowContentPublishPermissionsDialog();
                }
            }
        },
                      delegate(ApiModelContainer <APIUser> c)
        {
            Logout();
            error = c.Error;
            VRC.Core.Logger.Log("Error logging in: " + error);
        },
                      delegate(ApiModelContainer <API2FA> c)
        {
            if (c.Cookies.ContainsKey("auth"))
            {
                ApiCredentials.Set(username, username, "vrchat", c.Cookies["auth"]);
            }
            showTwoFactorAuthenticationEntry = true;
            onAuthenticationVerifiedAction   = OnAuthenticationCompleted;
        }
                      );
    }
Ejemplo n.º 5
0
        private static void Login()
        {
            APIUser.Login(username, password,
                          delegate(ApiModelContainer <APIUser> c)
            {
                APIUser user = c.Model as APIUser;
                if (c.Cookies.ContainsKey("auth"))
                {
                    ApiCredentials.Set(user.username, username, "vrchat", c.Cookies["auth"]);
                }
                else
                {
                    ApiCredentials.SetHumanName(user.username);
                }
                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(ApiModelContainer <APIUser> c)
            {
                Logout();
                error = c.Error;
                VRC.Core.Logger.Log("Error logging in: " + error);
            },
                          delegate(ApiModelContainer <API2FA> c)
            {
                API2FA model2FA = c.Model as API2FA;
                if (c.Cookies.ContainsKey("auth"))
                {
                    ApiCredentials.Set(username, username, "vrchat", c.Cookies["auth"]);
                }
                enter2faWindow = EditorWindow.GetWindow <Enter2faCodeEditorWindow>("VRChat 2FA");
                enter2faWindow.SetCredentialsAndVerificationHandling(username, password, OnAuthenticationCompleted);
                enter2faWindow.Show();
            }
                          );
        }
Ejemplo 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);

                if (!APIUser.CurrentUser.canPublishAllContent)
                {
                    if (UnityEditor.SessionState.GetString("HasShownContentPublishPermissionsDialogForUser", "") != user.id)
                    {
                        UnityEditor.SessionState.SetString("HasShownContentPublishPermissionsDialogForUser", user.id);
                        VRC_SdkControlPanel.ShowContentPublishPermissionsDialog();
                    }
                }
            },
                delegate(string message)
            {
                signingIn      = false;
                storedUsername = null;
                storedPassword = null;
                error          = message;
                APIUser.Logout();
                VRC.Core.Logger.Log("Error logging in: " + message);
            }
                );
        }
Ejemplo n.º 7
0
 private static bool VerifyCredentials()
 {
     if (!RemoteConfig.IsInitialized())
     {
         RemoteConfig.Init((Action)null, (Action)null);
     }
     if (!APIUser.get_IsLoggedInWithCredentials() && ApiCredentials.Load())
     {
         APIUser.FetchCurrentUser((Action <ApiModelContainer <APIUser> >) delegate(ApiModelContainer <APIUser> c)
         {
             AnalyticsSDK.LoggedInUserChanged(c.get_Model() as APIUser);
         }, (Action <ApiModelContainer <APIUser> >)null);
     }
     if (!APIUser.get_IsLoggedInWithCredentials())
     {
         GUILayout.Label("Please use the \"VRChat SDK/Settings\" window to log in.", EditorStyles.get_boldLabel(), (GUILayoutOption[])new GUILayoutOption[0]);
         return(false);
     }
     return(true);
 }
Ejemplo n.º 8
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);
            }
                );
        }
Ejemplo n.º 9
0
    public static void InitAccount()
    {
        if (isInitialized)
        {
            return;
        }

        if (!APIUser.IsLoggedIn && ApiCredentials.Load())
        {
            APIUser.FetchCurrentUser((c) => AnalyticsSDK.LoggedInUserChanged(c.Model as APIUser), null);
        }

        clientInstallPath = SDKClientUtilities.GetSavedVRCInstallPath();
        if (string.IsNullOrEmpty(clientInstallPath))
        {
            clientInstallPath = SDKClientUtilities.LoadRegistryVRCInstallPath();
        }

        signingIn     = false;
        isInitialized = true;

        ClearContent();
    }
Ejemplo n.º 10
0
    private static void AttemptLogin(string username = null, string password = null, Action successcallback = null)
    {
        if (selected_user_index >= add_index && (username == null || password == null))
        {
            return;
        }
        if (username == null)
        {
            username = usernames[selected_user_index];
        }
        if (password == null)
        {
            password = p_passwords[selected_user_index];
        }

        signingIn = true;
        APIUser.Login(username, password,
                      delegate(ApiModelContainer <APIUser> c)
        {
            APIUser user = c.Model as APIUser;
            if (c.Cookies.ContainsKey("auth"))
            {
                ApiCredentials.Set(user.username, username, "vrchat", c.Cookies["auth"]);
            }
            else
            {
                ApiCredentials.SetHumanName(user.username);
            }
            signingIn = false;
            error     = null;
            EditorPrefs.SetString("sdk#username", username);
            EditorPrefs.SetString("sdk#password", password);
            AnalyticsSDK.LoggedInUserChanged(user);

            if (!APIUser.CurrentUser.canPublishAllContent)
            {
                if (UnityEditor.SessionState.GetString("HasShownContentPublishPermissionsDialogForUser", "") != user.id)
                {
                    UnityEditor.SessionState.SetString("HasShownContentPublishPermissionsDialogForUser", user.id);
                    VRCSdkControlPanel.ShowContentPublishPermissionsDialog();
                }
            }
            ;
            if (successcallback != null)
            {
                successcallback.Invoke();
            }
            AS_Window.RepaintActiveWindow();
        },
                      delegate(ApiModelContainer <APIUser> c)
        {
            Logout(false);
            error = c.Error;
            VRC.Core.Logger.Log("Error logging in: " + error);
            AS_Window.RepaintActiveWindow();
        },
                      delegate(ApiModelContainer <API2FA> c)
        {
            if (c.Cookies.ContainsKey("auth"))
            {
                ApiCredentials.Set(username, username, "vrchat", c.Cookies["auth"]);
            }
            AS_Window.showTwoFactorAuthenticationEntry = true;
            onAuthenticationVerifiedAction             = OnAuthenticationCompleted;
            AS_Window.RepaintActiveWindow();
        }
                      );
    }