Example #1
0
        private bool Validate()
        {
            var message = string.Empty;

            if (string.IsNullOrWhiteSpace(_oldPass))
            {
                message = Translations.GetTranslation()["OldPassValid"].ToString();
            }
            else if (AESEncryptor.decryptPassword(GlobalBase.CurrentUser.Password) != _oldPass)
            {
                message = Translations.GetTranslation()["ResPassCurPassNotMatch"].ToString();
            }
            else if (_newPass.Length < 8 || string.IsNullOrWhiteSpace(_newPass) || _newPass == string.Empty || !Regex.IsMatch(_newPass, @"^[a-zA-Z0-9]{8,}$"))
            {
                message = Translations.GetTranslation()["PassValidation"].ToString();
            }

            if (message != string.Empty)
            {
                Application.Current.Dispatcher.Invoke(new Action((() => { CustomMessageBox.Show(Translations.GetTranslation()["Error"].ToString(), message); })));
                return(false);
            }

            return(true);
        }
Example #2
0
        private void SendPassWithMail(User user)
        {
            try
            {
                var from = new MailAddress("*****@*****.**"); // make custom mail adress
                var to   = new MailAddress(user.Email);

                var newPas = AESEncryptor.encryptPassword(RandomNumberGenerator.RandomPassword());
                user.Password = newPas;

                UserServiceClient.AddOrUpdateUser(user);

                var message = new MailMessage(from, to);
                message.Subject = "Password restore";
                message.Body    = "Your pass - " + AESEncryptor.decryptPassword(newPas);

                var smtp = new SmtpClient("smtp.gmail.com", 587);
                smtp.Credentials = new NetworkCredential("*****@*****.**", "messageApp1");
                smtp.EnableSsl   = true;
                smtp.SendMailAsync(message);

                Application.Current.Dispatcher.Invoke(new Action((() =>
                {
                    try
                    {
                        CustomMessageBox.Show(Translations.GetTranslation()["RestorePass"].ToString(), Application.Current.Resources.MergedDictionaries[4]["EmailSend"].ToString());
                        IsSending = false;
                    }
                    finally
                    {
                    }
                })));
            }
            finally
            {
            }
        }