예제 #1
0
        /// <summary>
        /// Verify and create the authenticator if needed
        /// </summary>
        /// <returns>true is successful</returns>
        private bool verifyAuthenticator()
        {
            if (this.tabControl1.SelectedIndex == 0)
            {
                if (this.Authenticator.AuthenticatorData == null)
                {
                    WinAuthForm.ErrorDialog(this.Owner, "You need to create an authenticator and attach it to your account");
                    return(false);
                }
            }
            else
            {
                if (restoreQuestion1Label.Text.Length == 0)
                {
                    restoreGetQuestionsButton_Click(null, null);
                    return(false);
                }

                string email    = this.restoreEmailField.Text.Trim();
                string password = this.restorePasswordField.Text.Trim();
                string deviceId = this.restoreDeviceIdField.Text.Trim();
                string answer1  = this.restoreAnswer1Field.Text;
                string answer2  = this.restoreAnswer2Field.Text;
                if (deviceId.Length == 0 || (restoreQuestion2Label.Text.Length != 0 && answer1.Length == 0) || (restoreQuestion2Label.Text.Length != 0 && answer2.Length == 0))
                {
                    WinAuthForm.ErrorDialog(this.Owner, "Please enter the device ID and answers to your secret questions");
                    return(false);
                }

                try
                {
                    TrionAuthenticator authenticator = new TrionAuthenticator();
                    authenticator.Restore(email, password, deviceId, answer1, answer2);
                    this.Authenticator.AuthenticatorData = authenticator;
                }
                catch (InvalidRestoreResponseException irre)
                {
                    WinAuthForm.ErrorDialog(this.Owner, "Unable to restore the authenticator: " + irre.Message, irre);
                    return(false);
                }
                catch (Exception ex)
                {
                    WinAuthForm.ErrorDialog(this.Owner, "An error occured restoring the authenticator: " + ex.Message, ex);
                    return(false);
                }
            }

            return(true);
        }
예제 #2
0
        /// <summary>
        /// Verify and create the authenticator if needed
        /// </summary>
        /// <returns>true is successful</returns>
        private bool verifyAuthenticator()
        {
            if (this.tabControl1.SelectedIndex == 0)
            {
                if (this.Authenticator.AuthenticatorData == null)
                {
                    WinAuthForm.ErrorDialog(this.Owner, "您需要创建身份验证器并将其附加到您的帐户");
                    return(false);
                }
            }
            else
            {
                if (restoreQuestion1Label.Text.Length == 0)
                {
                    restoreGetQuestionsButton_Click(null, null);
                    return(false);
                }

                string email    = this.restoreEmailField.Text.Trim();
                string password = this.restorePasswordField.Text.Trim();
                string deviceId = this.restoreDeviceIdField.Text.Trim();
                string answer1  = this.restoreAnswer1Field.Text;
                string answer2  = this.restoreAnswer2Field.Text;
                if (deviceId.Length == 0 || (restoreQuestion2Label.Text.Length != 0 && answer1.Length == 0) || (restoreQuestion2Label.Text.Length != 0 && answer2.Length == 0))
                {
                    WinAuthForm.ErrorDialog(this.Owner, "请输入设备ID和您的安全问题的答案");
                    return(false);
                }

                try
                {
                    TrionAuthenticator authenticator = new TrionAuthenticator();
                    authenticator.Restore(email, password, deviceId, answer1, answer2);
                    this.Authenticator.AuthenticatorData = authenticator;
                }
                catch (InvalidRestoreResponseException irre)
                {
                    WinAuthForm.ErrorDialog(this.Owner, "无法恢复验证器: " + irre.Message, irre);
                    return(false);
                }
                catch (Exception ex)
                {
                    WinAuthForm.ErrorDialog(this.Owner, "发生恢复验证器的错误: " + ex.Message, ex);
                    return(false);
                }
            }

            return(true);
        }
예제 #3
0
		/// <summary>
		/// Verify and create the authenticator if needed
		/// </summary>
		/// <returns>true is successful</returns>
		private bool verifyAuthenticator()
		{
			if (this.tabControl1.SelectedIndex == 0)
			{
				if (this.Authenticator.AuthenticatorData == null)
				{
					WinAuthForm.ErrorDialog(this.Owner, "You need to create an authenticator and attach it to your account");
					return false;
				}
			}
			else
			{				
				if (restoreQuestion1Label.Text.Length == 0)
				{
					restoreGetQuestionsButton_Click(null, null);
					return false;
				}

				string email = this.restoreEmailField.Text.Trim();
				string password = this.restorePasswordField.Text.Trim();
				string deviceId = this.restoreDeviceIdField.Text.Trim();
				string answer1 = this.restoreAnswer1Field.Text;
				string answer2 = this.restoreAnswer2Field.Text;
				if (deviceId.Length == 0 || (restoreQuestion2Label.Text.Length != 0 && answer1.Length == 0) || (restoreQuestion2Label.Text.Length != 0 && answer2.Length == 0))
				{
					WinAuthForm.ErrorDialog(this.Owner, "Please enter the device ID and answers to your secret questions");
					return false;
				}

				try
				{
					TrionAuthenticator authenticator = new TrionAuthenticator();
					authenticator.Restore(email, password, deviceId, answer1, answer2);
					this.Authenticator.AuthenticatorData = authenticator;
				}
				catch (InvalidRestoreResponseException irre)
				{
					WinAuthForm.ErrorDialog(this.Owner, "Unable to restore the authenticator: " + irre.Message, irre);
					return false;
				}
				catch (Exception ex)
				{
					WinAuthForm.ErrorDialog(this.Owner, "An error occured restoring the authenticator: " + ex.Message, ex);
					return false;
				}
			}

			return true;
		}