/// <summary>
        /// Perform QuantConnect authentication
        /// </summary>
        /// <param name="serviceProvider">Visual Studio services provider</param>
        /// <param name="explicitLogin">User explicitly clicked Log In button</param>
        /// <param name="showLoginDialog">If true LoginDialog will be shown, careful it blocks UI</param>
        /// <returns>true if user logged into QuantConnect, false otherwise</returns>
        public async Task <bool> Login(IServiceProvider serviceProvider, bool explicitLogin, bool showLoginDialog = true)
        {
            VSActivityLog.Info("Logging in");

            var authorizationManager = AuthorizationManager.GetInstance();

            if (authorizationManager.IsLoggedIn())
            {
                VSActivityLog.Info("Already logged in");
                return(true);
            }

            var previousCredentials = CredentialsManager.GetLastCredential();

            if (!explicitLogin && await LoggedInWithLastStorredPassword(previousCredentials))
            {
                VSActivityLog.Info("Logged in with previously storred credentials");
                return(true);
            }

            if (showLoginDialog)
            {
                return(LoginWithDialog(serviceProvider, previousCredentials));
            }
            VsUtils.DisplayInStatusBar(serviceProvider, "Please login to QuantConnect");
            return(false);
        }
Ejemplo n.º 2
0
        private bool LoginWithDialog(IServiceProvider serviceProvider, Credentials?previousCredentials)
        {
            var logInDialog = new LoginDialog(AuthorizationManager.GetInstance(), previousCredentials, serviceProvider);

            VsUtils.DisplayDialogWindow(logInDialog);

            var credentials = logInDialog.GetCredentials();

            if (credentials.HasValue)
            {
                VSActivityLog.Info("Storing credentials");
                CredentialsManager.StoreCredentials(credentials.Value);
                return(true);
            }
            else
            {
                VSActivityLog.Info("Login cancelled");
                return(false);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Perform QuantConnect authentication
        /// </summary>
        /// <param name="serviceProvider">Visual Studio services provider</param>
        /// <param name="explicitLogin">User explicitly clicked Log In button</param>
        /// <returns>true if user logged into QuantConnect, false otherwise</returns>
        public bool Login(IServiceProvider serviceProvider, bool explicitLogin)
        {
            VSActivityLog.Info("Logging in");

            var authorizationManager = AuthorizationManager.GetInstance();

            if (authorizationManager.IsLoggedIn())
            {
                VSActivityLog.Info("Already logged in");
                return(true);
            }

            var previousCredentials = CredentialsManager.GetLastCredential();

            if (!explicitLogin && LoggedInWithLastStorredPassword(previousCredentials))
            {
                VSActivityLog.Info("Logged in with previously storred credentials");
                return(true);
            }

            return(LoginWithDialog(serviceProvider, previousCredentials));
        }