Example #1
5
        private void btnChangeCode_Click(object sender, EventArgs e)
        {
            switch (MessageBox.Show(Resources.PromptNewKey, Resources.MessageBoxCaption, MessageBoxButtons.OKCancel)) {
                case DialogResult.OK:
                    var accountCode = Membership.GeneratePassword(16, 6);
                    var key = Encoding.ASCII.GetBytes(accountCode);
                    Settings.Default.tfbin = Convert.ToBase64String(ProtectedData.Protect(key, null, DataProtectionScope.CurrentUser));

                    var tfa = new TwoFactorAuthenticator();
                    var info = tfa.GenerateSetupCode("CAESAR", accountCode, 300, 300);

                    MessageBox.Show(Resources.MessageAccountCode + info.ManualEntryKey, Resources.MessageBoxCaption, MessageBoxButtons.OK);
                    break;

                case DialogResult.Cancel:
                    return;
            }
        }
        private void frmAccountIssuer_Load(object sender, EventArgs e)
        {
            accountCode = Membership.GeneratePassword(16, 6);

            var tfa = new TwoFactorAuthenticator();
            info = tfa.GenerateSetupCode("CAESAR", accountCode, 300, 300);
        }
Example #3
0
        private void OK_Click(object sender, EventArgs e)
        {
            var tfa = new TwoFactorAuthenticator();
            var verified = tfa.ValidateTwoFactorPIN(account, PasswordTextBox.Text);

            DialogResult = verified ? DialogResult.OK : DialogResult.Abort;
        }
        public ActionResult Index()
        {
            TwoFactorAuthenticator tfa = new TwoFactorAuthenticator();
            var setupCode = tfa.GenerateSetupCode("Huan Test App", "*****@*****.**", "123456", 150, 150);

            ViewBag.QrCodeSetupImageUrl = setupCode.QrCodeSetupImageUrl;
            ViewBag.ManualEntryKey = setupCode.ManualEntryKey;

            return View();
        }
        public ActionResult VerifyTwoFactor()
        {
            var userValue = Request.Params.Get("userValue");

            TwoFactorAuthenticator tfa = new TwoFactorAuthenticator();
            bool isCorrectPIN = tfa.ValidateTwoFactorPIN("123456", userValue);

            return new ContentResult()
            {
                Content = isCorrectPIN.ToString()
            };
        }