Пример #1
0
        /// <summary>
        /// Logins the user into the current mod repository.
        /// </summary>
        /// <param name="p_vmlViewModel">The view model that provides the data and operations for this view.</param>
        /// <returns><c>true</c> if the user was successfully logged in;
        /// <c>false</c> otherwise</returns>
        protected bool LoginUser()
        {
            string strMessage       = String.Format("You must log into the {0} website.", ModManager.ModRepository.Name);
            string strCancelWarning = String.Format("If you do not login {0} will close.", ModManager.EnvironmentInfo.Settings.ModManagerName);

            strError = booCredentialsExpired ? "You need to login using your Nexus username and password." : strError;

            LoginFormVM = new LoginFormVM(ModManager.EnvironmentInfo, ModManager.ModRepository, ModManager.GameMode.ModeTheme, strMessage, strError, strCancelWarning);

            LoginForm = new LoginForm(LoginFormVM, this);
            LoginForm.Authenticating += new EventHandler(LoginForm_Authenticating);
            LoginForm.ShowDialog();
            if (Status == TaskStatus.Complete)
            {
                return(true);
            }
            else
            {
                if (Status == TaskStatus.Incomplete)
                {
                    OverallMessage = "You are not logged in.";
                }
                return(false);
            }
        }
Пример #2
0
 /// <summary>
 /// A simple constructor the initializes the object with the given values.
 /// </summary>
 /// <param name="viewModel">The view model that provides the data and operations for this view.</param>
 /// <param name="loginTask"></param>
 public LoginForm(LoginFormVM viewModel, LoginFormTask loginTask)
 {
     InitializeComponent();
     lblError.Visible      = true;
     lblError.TextChanged += lblError_TextChanged;
     FormClosed           += LoginForm_FormClosed;
     _loginTask            = loginTask;
     ViewModel             = viewModel;
 }
Пример #3
0
 /// <summary>
 /// A simple constructor the initializes the object with the given values.
 /// </summary>
 /// <param name="p_vmlViewModel">The view model that provides the data and operations for this view.</param>
 public LoginForm(LoginFormVM p_vmlViewModel, LoginFormTask p_lftLoginTask)
 {
     InitializeComponent();
     lblError.Visible      = true;
     lblError.TextChanged += new EventHandler(lblError_TextChanged);
     this.FormClosed      += new FormClosedEventHandler(LoginForm_FormClosed);
     m_lftLoginTask        = p_lftLoginTask;
     ViewModel             = p_vmlViewModel;
 }
Пример #4
0
		/// <summary>
		/// A simple constructor the initializes the object with the given values.
		/// </summary>
		/// <param name="p_vmlViewModel">The view model that provides the data and operations for this view.</param>
		public LoginForm(LoginFormVM p_vmlViewModel, LoginFormTask p_lftLoginTask)
        {
			InitializeComponent();
			lblError.Visible = true;
			lblError.TextChanged += new EventHandler(lblError_TextChanged);
            this.FormClosed += new FormClosedEventHandler(LoginForm_FormClosed);
            m_lftLoginTask = p_lftLoginTask;
			ViewModel = p_vmlViewModel;
		}
        /// <summary>
        /// Logins the user into the current mod repository.
        /// </summary>
        /// <param name="p_vmlViewModel">The view model that provides the data and operations for this view.</param>
        /// <returns><c>true</c> if the user was successfully logged in;
        /// <c>false</c> otherwise</returns>
        protected bool Login(LoginFormVM p_vmlViewModel)
        {
            if (InvokeRequired)
            {
                return((bool)Invoke((Func <LoginFormVM, bool>)Login, p_vmlViewModel));
            }
            LoginForm frmLogin = new LoginForm(p_vmlViewModel, null);

            return(frmLogin.ShowDialog(this) == DialogResult.OK);
        }
Пример #6
0
        private void LoginForm_Authenticating(object sender, EventArgs e)
        {
            LoginForm.CheckForIllegalCrossThreadCalls = false;
            LoginFormVM.ErrorMessage = "Attempting to connect to login servers";

            Status         = TaskStatus.Running;
            OverallMessage = "Sending login data...";
            if (LoginFormVM.Login())
            {
                Status                 = TaskStatus.Complete;
                OverallMessage         = "Logged in.";
                LoginForm.DialogResult = DialogResult.OK;
            }
            else
            {
                Status         = TaskStatus.Error;
                OverallMessage = "Login error: " + LoginFormVM.ErrorMessage;
            }
        }
		/// <summary>
		/// Logins the user into the current mod repository.
		/// </summary>
		/// <param name="p_gmdGameMode">The current game mode.</param>
		/// <param name="p_mrpModRepository">The mod repository to use to retrieve mods and mod metadata.</param>
		/// <returns><c>true</c> if the user was successfully logged in;
		/// <c>false</c> otherwise</returns>
		protected bool Login(IGameMode p_gmdGameMode, IModRepository p_mrpModRepository)
		{
			if (EnvironmentInfo.Settings.RepositoryAuthenticationTokens[p_mrpModRepository.Id] == null)
				EnvironmentInfo.Settings.RepositoryAuthenticationTokens[p_mrpModRepository.Id] = new KeyedSettings<string>();

			Dictionary<string, string> dicAuthTokens = new Dictionary<string, string>(EnvironmentInfo.Settings.RepositoryAuthenticationTokens[p_mrpModRepository.Id]);
			bool booCredentialsExpired = false;
			string strError = String.Empty;

			try
			{
				booCredentialsExpired = !p_mrpModRepository.Login(dicAuthTokens);
			}
			catch (RepositoryUnavailableException e)
			{
				strError = e.Message;
				dicAuthTokens.Clear();
			}

			if ((dicAuthTokens.Count == 0) || booCredentialsExpired)
			{
				string strMessage = String.Format("You must log into the {0} website.", p_mrpModRepository.Name);
				string strCancelWarning = String.Format("If you do not login {0} will close.", EnvironmentInfo.Settings.ModManagerName);
				strError = booCredentialsExpired ? "You need to login using your Nexus username and password." : strError;
				LoginFormVM vmlLoginVM = new LoginFormVM(EnvironmentInfo, p_mrpModRepository, p_gmdGameMode.ModeTheme, strMessage, strError, strCancelWarning);
				return LoginUser(vmlLoginVM);
			}
			return true;
		}
        /// <summary>
        /// Logins the user into the current mod repository.
        /// </summary>
        /// <param name="p_vmlViewModel">The view model that provides the data and operations for this view.</param>
        /// <returns><c>true</c> if the user was successfully logged in;
        /// <c>false</c> otherwise</returns>
        protected bool LoginUser()
        {
			string strMessage = String.Format("You must log into the {0} website.", ModManager.ModRepository.Name);
			string strCancelWarning = String.Format("If you do not login {0} will close.", ModManager.EnvironmentInfo.Settings.ModManagerName);
            strError = booCredentialsExpired ? "You need to login using your Nexus username and password." : strError;

			LoginFormVM = new LoginFormVM(ModManager.EnvironmentInfo, ModManager.ModRepository, ModManager.GameMode.ModeTheme, strMessage, strError, strCancelWarning);

			LoginForm = new LoginForm(LoginFormVM, this);
			LoginForm.Authenticating += new EventHandler(LoginForm_Authenticating);
			LoginForm.ShowDialog();
			if (Status == TaskStatus.Complete)
				return true;
			else
			{
				if (Status == TaskStatus.Incomplete)
					OverallMessage = "You are not logged in.";
				return false;
			}
        }
		/// <summary>
		/// Logins the user into the current mod repository.
		/// </summary>
		/// <param name="p_vmlViewModel">The view model that provides the data and operations for this view.</param>
		/// <returns><c>true</c> if the user was successfully logged in;
		/// <c>false</c> otherwise</returns>
		protected bool Login(LoginFormVM p_vmlViewModel)
		{
			if (InvokeRequired)
				return (bool)Invoke((Func<LoginFormVM, bool>)Login, p_vmlViewModel);
			LoginForm frmLogin = new LoginForm(p_vmlViewModel, null);
			return frmLogin.ShowDialog(this) == DialogResult.OK;
		}