예제 #1
0
 public static void RepaintActiveWindow()
 {
     window = GetWindow <AS_Window>();
     if (window != null)
     {
         window.Repaint();
     }
 }
예제 #2
0
 public static void AddAccount(string username, string password)
 {
     adding_username = username;
     adding_password = password;
     //test credentials
     AttemptLogin(username, password, delegate()
     {
         SaveCredentials(username, password);
         AS_Window.RepaintActiveWindow();
     });
 }
예제 #3
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();
        }
                      );
    }