コード例 #1
0
        private void PwdGenUI_Load(object sender, EventArgs e)
        {
            var RK = Registry.CurrentUser.OpenSubKey("Software\\PWGEN");

            if (RK != null)
            {
                menuStrip1.Visible = true;
            }
            pwdGen = new PasswordGenerator.PasswordGenerator();
            mediumToolStripMenuItem_Click();
            btnGenerate_Click();
            btnGenerate.Focus();
        }
コード例 #2
0
        public ActionResult ForgotPassword(MailVM mailView)
        {
            string[] mailTo;
            MailDTO  mail;
            bool     isMailSent      = false;;
            bool     isResetPassword = false;
            int      UserMasterId;

            string newPassword          = null;
            string newPasswordEncrypted = null;

            if (mailView != null)
            {
                UserMasterId = _mail.CheckMail(mailView.To);
                if (UserMasterId != 0)
                {
                    PasswordGenerator.PasswordGenerator passGen = new PasswordGenerator.PasswordGenerator();
                    passGen.InitializePasswordArrays();

                    PasswordVM passVM = new PasswordVM();
                    passVM.CapitalLettersLength    = 1;
                    passVM.DigitsLength            = 1;
                    passVM.SmallLettersLength      = 3;
                    passVM.SpecialCharactersLength = 1;
                    passVM.PasswordLength          = 6;

                    newPassword = passGen.GeneratePassword(passVM); // get password

                    if (!string.IsNullOrEmpty(newPassword))
                    {
                        newPasswordEncrypted = encrypt.encryption(newPassword);//Encrypt Password

                        isResetPassword = _resetPassSvc.ResetPassword(newPasswordEncrypted, UserMasterId);
                        if (isResetPassword)
                        {
                            mail                       = new MailDTO();
                            mail.From                  = "*****@*****.**";
                            mail.IsBodyHtml            = false;
                            mail.MailSubject           = "Reset Password";
                            mail.MailBody              = "Your new password which is reset is: " + newPassword;
                            mail.SmtpPort              = 587;
                            mail.SmtpServer            = "smtp.gmail.com";
                            mail.EnableSSL             = true;
                            mail.UseDefaultCredentials = true;
                            //split the ';' separated string To a List
                            mailTo      = mailView.To.Split(';');
                            mail.ToList = new List <string>();
                            for (int i = 0; i < mailTo.Length; i++)
                            {
                                mail.ToList.Add(mailTo[i]);
                            }
                            //instantiate CC and Bcc List if possible
                            isMailSent = _mail.SendMail(mail);// call SendMail method to send the mail
                            if (isMailSent)
                            {
                                mailView.SuccessOrFailureMessage = "Your new password: "******" is sent to mail";
                                mailView.MessageColor            = "green";
                            }
                            else
                            {
                                mailView.SuccessOrFailureMessage = "Your password was not reset in a proper manner";
                                mailView.MessageColor            = "red";
                            }
                        }
                    }
                }
                else
                {
                    mailView.SuccessOrFailureMessage = "Sorry your email was incorect. Please enter again";
                    mailView.MessageColor            = "red";
                }
            }
            return(View(mailView));
        }
コード例 #3
0
 private void PwdGenUI_Load(object sender, EventArgs e)
 {
     var RK = Registry.CurrentUser.OpenSubKey("Software\\PWGEN");
     if (RK != null)
     {
         menuStrip1.Visible = true;
     }
     pwdGen = new PasswordGenerator.PasswordGenerator();
     mediumToolStripMenuItem_Click();
     btnGenerate_Click();
     btnGenerate.Focus();
 }