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);
            }
                          );
        }
Exemplo n.º 2
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;
        }
                      );
    }
Exemplo n.º 3
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();
            }
                          );
        }
Exemplo n.º 4
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();
        }
                      );
    }