private PasswordInteraction CreateAndInvokeInteraction(Job job, bool retype)
        {
            var sb = new StringBuilder();

            sb.AppendLine(_translation.RecipientsText);
            sb.AppendLine(job.Profile.EmailSmtpSettings.Recipients);
            if (retype)
            {
                sb.AppendLine();
                sb.AppendLine(_translation.RetypeSmtpPwMessage);
            }

            var title       = _translation.SmtpPasswordTitle;
            var description = _translation.SmtpPasswordDescription;

            var button      = retype ? PasswordMiddleButton.None : PasswordMiddleButton.Skip;
            var interaction = new PasswordInteraction(button, title, description, false)
            {
                Password  = job.Passwords.SmtpPassword,
                IntroText = sb.ToString()
            };

            _interactionInvoker.Invoke(interaction);

            return(interaction);
        }
        private PasswordInteraction CreateAndInvokeInteraction(Job job, bool retype)
        {
            var sb = new StringBuilder();

            sb.AppendLine(_translator.GetTranslation("pdfforge.PDFCreator.UI.Views.ActionControls.EmailClientActionControl", "RecipientsText.Text"));
            sb.AppendLine(job.Profile.EmailSmtpSettings.Recipients);
            if (retype)
            {
                sb.AppendLine();
                sb.AppendLine(_translator.GetTranslation("InteractiveWorkflow", "RetypeSmtpPwMessage"));
            }

            var title       = _translator.GetTranslation("EmailClientActionSettings", "SmtpPasswordTitle");
            var description = _translator.GetTranslation("EmailClientActionSettings", "SmtpPasswordDescription");

            var button      = retype ? PasswordMiddleButton.None : PasswordMiddleButton.Skip;
            var interaction = new PasswordInteraction(button, title, description, false)
            {
                Password  = job.Passwords.SmtpPassword,
                IntroText = sb.ToString()
            };

            _interactionInvoker.Invoke(interaction);

            return(interaction);
        }
Esempio n. 3
0
        private bool TrySetJobPasswords(Job job, ConversionProfile profile)
        {
            if (!string.IsNullOrWhiteSpace(profile.EmailSmtpSettings.Password))
            {
                job.Passwords.SmtpPassword = profile.EmailSmtpSettings.Password;
                return(true);
            }

            var sb = new StringBuilder();

            sb.AppendLine(_translation.RecipientsText);
            sb.AppendLine(profile.EmailSmtpSettings.Recipients);

            var title       = _translation.SmtpPasswordTitle;
            var description = _translation.SmtpPasswordDescription;

            var interaction = new PasswordInteraction(PasswordMiddleButton.None, title, description, false);

            interaction.IntroText = sb.ToString();

            _interactionInvoker.Invoke(interaction);

            if (interaction.Result != PasswordResult.StorePassword)
            {
                return(false);
            }

            job.Passwords.SmtpPassword = interaction.Password;
            return(true);
        }
        private void SetPasswordExecute(object obj)
        {
            var sb = new StringBuilder();

            sb.AppendLine(Translation.RecipientsText);
            sb.AppendLine(EmailSmtpSettings.Recipients);

            var title       = Translation.SmtpPasswordTitle;
            var description = Translation.SmtpPasswordDescription;

            var interaction = new PasswordInteraction(PasswordMiddleButton.Remove, title, description);

            interaction.Password  = EmailSmtpSettings.Password;
            interaction.IntroText = sb.ToString();

            _interactionInvoker.Invoke(interaction);

            if (interaction.Result == PasswordResult.StorePassword)
            {
                EmailSmtpSettings.Password = interaction.Password;
            }
            else if (interaction.Result == PasswordResult.StorePassword)
            {
                EmailSmtpSettings.Password = "";
            }
        }
Esempio n. 5
0
        private void Login_Click(object sender, RoutedEventArgs e)
        {
            string login    = loginBox.Text.ToLower();
            string password = passwordBox.Password;

            string hashedPassword = PasswordInteraction.GetPasswordHash(password);

            User user = mainWindow.unitOfWork.Users.GetUserByLoginAndPassword(login, hashedPassword);

            if (user == null)
            {
                MessageBox.Show("Неверный логин или пароль!", "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            MessageBox.Show("Вы успешно авторизовались!", "Информация");

            mainWindow.user = user;

            if (TeachersInteraction.IsTeacher(user))
            {
                mainWindow.Navigation.Navigate(new TeacherPage(mainWindow, TeachersInteraction.GetTeacherModel(user)));
            }
            else if (AdminsInteraction.IsAdmin(user))
            {
                mainWindow.Navigation.Navigate(new AdminPage(mainWindow));
            }
            else
            {
                mainWindow.Navigation.Navigate(new UserPage(mainWindow, user));
            }
        }
Esempio n. 6
0
        private void SetPasswordExecute(object obj)
        {
            var sb = new StringBuilder();

            sb.AppendLine(Translator.GetTranslation("pdfforge.PDFCreator.UI.Views.ActionControls.EmailClientActionControl", "RecipientsText.Text"));
            sb.AppendLine(EmailSmtpSettings.Recipients);

            var title       = Translator.GetTranslation("EmailClientActionSettings", "SmtpPasswordTitle");
            var description = Translator.GetTranslation("EmailClientActionSettings", "SmtpPasswordDescription");

            var interaction = new PasswordInteraction(PasswordMiddleButton.Remove, title, description);

            interaction.Password  = EmailSmtpSettings.Password;
            interaction.IntroText = sb.ToString();

            _interactionInvoker.Invoke(interaction);

            if (interaction.Result == PasswordResult.StorePassword)
            {
                EmailSmtpSettings.Password = interaction.Password;
            }
            else if (interaction.Result == PasswordResult.StorePassword)
            {
                EmailSmtpSettings.Password = "";
            }
        }
        private void Registration_Click(object sender, RoutedEventArgs e)
        {
            string first_name  = First_NameBox.Text;
            string middle_name = Middle_NameBox.Text;
            string last_name   = Last_NameBox.Text;

            string login = LoginBox.Text.ToLower();

            string password      = PasswordBox.Password;
            string password_copy = PasswordBox_copy.Password;

            if (password.Length != 0 && password != password_copy)
            {
                MessageBox.Show("Введённые пароли не совпадают!", "Ошибка!", MessageBoxButton.YesNo, MessageBoxImage.Error);
                return;
            }

            user.FirstName  = first_name;
            user.MiddleName = middle_name;
            user.LastName   = last_name;

            user.Login = login;
            if (password.Length != 0 && password_copy.Length != 0 && password == password_copy)
            {
                user.Password = PasswordInteraction.GetPasswordHash(password);
            }

            unitOfWork.Users.Update(user);
            unitOfWork.Db.SaveChanges();

            mainWindow.Navigation.Navigate(new TeacherPage(mainWindow, teacher));
        }
        public void CanSkip_WithRemovePasswordEnabled_IsFalse()
        {
            var viewModel   = new PasswordViewModel();
            var interaction = new PasswordInteraction(PasswordMiddleButton.Remove, "", "");
            var helper      = new InteractionHelper <PasswordInteraction>(viewModel, interaction);

            Assert.IsFalse(viewModel.CanSkip);
        }
        public void CanSkip_WithSkipEnabled_IsTrue()
        {
            var viewModel   = new PasswordViewModel(new PasswordWindowTranslation());
            var interaction = new PasswordInteraction(PasswordMiddleButton.Skip, "", "");
            var helper      = new InteractionHelper <PasswordInteraction>(viewModel, interaction);

            Assert.IsTrue(viewModel.CanSkip);
        }
Esempio n. 10
0
        public DesignTimePasswordViewModel()
        {
            var interaction = new PasswordInteraction(PasswordMiddleButton.Remove, "Set password (Design-Time value)", "Please enter your password:"******"123456789";
            interaction.IntroText = "An intro text can be displayed here.";
            SetInteraction(interaction);
        }
Esempio n. 11
0
        public void OkCommand_OnExecute_CompletesInteraction()
        {
            var viewModel   = new PasswordViewModel(new PasswordWindowTranslation());
            var interaction = new PasswordInteraction(PasswordMiddleButton.Skip, "", "");
            var helper      = new InteractionHelper <PasswordInteraction>(viewModel, interaction);

            viewModel.OkCommand.Execute(null);

            Assert.AreEqual(PasswordResult.StorePassword, interaction.Result);
            Assert.IsTrue(helper.InteractionIsFinished);
        }
        public void SkipCommand_OnExecute_FinishesInteraction()
        {
            var viewModel   = new PasswordViewModel();
            var interaction = new PasswordInteraction(PasswordMiddleButton.Skip, "", "");
            var helper      = new InteractionHelper <PasswordInteraction>(viewModel, interaction);

            viewModel.Password = "******";

            viewModel.SkipCommand.Execute(null);

            Assert.AreEqual(PasswordResult.Skip, interaction.Result);
            Assert.AreEqual("", interaction.Password);
            Assert.IsTrue(helper.InteractionIsFinished);
        }
Esempio n. 13
0
        public void RemoveCommand_OnExecute_FinishesInteraction()
        {
            var viewModel   = new PasswordViewModel(new PasswordWindowTranslation());
            var interaction = new PasswordInteraction(PasswordMiddleButton.Remove, "", "")
            {
                Password = "******"
            };
            var helper = new InteractionHelper <PasswordInteraction>(viewModel, interaction);

            viewModel.RemoveCommand.Execute(null);

            Assert.AreEqual(PasswordResult.RemovePassword, interaction.Result);
            Assert.AreEqual("", interaction.Password);
            Assert.IsTrue(helper.InteractionIsFinished);
        }
Esempio n. 14
0
        public void FtpPassword_OnSet_WritesToInteractionAndCallCanExecuteChanged()
        {
            var interacton = new PasswordInteraction(PasswordMiddleButton.Skip, "", "");
            var viewModel  = new PasswordViewModel(new PasswordWindowTranslation());

            viewModel.SetInteraction(interacton);

            var canExecuteChanged = false;

            viewModel.OkCommand.CanExecuteChanged += (sender, args) => canExecuteChanged = true;

            viewModel.Password = "******";

            Assert.AreEqual("MyPassword", interacton.Password);
            Assert.IsTrue(canExecuteChanged);
        }
Esempio n. 15
0
        public void OnInteractionSet_SetsPasswordsInView()
        {
            var viewModel         = new PasswordViewModel(new PasswordWindowTranslation());
            var canExecuteChanged = false;

            viewModel.OkCommand.CanExecuteChanged += (sender, args) => canExecuteChanged = true;
            var interaction = new PasswordInteraction(PasswordMiddleButton.Skip, "", "")
            {
                Password = "******"
            };

            var actionWasCalled = false;

            viewModel.SetPasswordAction = x => actionWasCalled = true;

            viewModel.SetInteraction(interaction);
            Assert.IsTrue(actionWasCalled);
            Assert.IsTrue(canExecuteChanged);
        }
        private void SetPasswordExecute(object obj)
        {
            var title = Translator.GetTranslation("FtpActionSettings", "PasswordTitle");
            var passwordDescription = Translator.GetTranslation("FtpActionSettings", "PasswordDescription");

            var interaction = new PasswordInteraction(PasswordMiddleButton.Remove, title, passwordDescription);

            interaction.Password = Password;

            _interactionInvoker.Invoke(interaction);

            if (interaction.Result == PasswordResult.StorePassword)
            {
                Password = interaction.Password;
            }
            else if (interaction.Result == PasswordResult.RemovePassword)
            {
                Password = "";
            }
        }
Esempio n. 17
0
        private void TimeServerPasswordExecute(object obj)
        {
            var title       = Translation.TimeServerPasswordTitle;
            var description = Translation.TimeServerPasswordDescription;
            var interaction = new PasswordInteraction(PasswordMiddleButton.Remove, title, description, false);

            interaction.Password = CurrentProfile.PdfSettings.Signature.TimeServerPassword;

            _interactionInvoker.Invoke(interaction);

            if (interaction.Result == PasswordResult.StorePassword)
            {
                CurrentProfile.PdfSettings.Signature.TimeServerPassword = interaction.Password;
            }
            else if (interaction.Result == PasswordResult.RemovePassword)
            {
                CurrentProfile.PdfSettings.Signature.TimeServerPassword = "";
            }
            RaisePropertyChanged(nameof(CurrentProfile));
        }
        private PasswordInteraction CreateAndInvokeInteraction(Job job, bool retype)
        {
            var sb = new StringBuilder();

            if (retype)
            {
                sb.AppendLine(_translator.GetTranslation("InteractiveWorkflow", "RetypeSmtpPwMessage"));
            }

            var title       = _translator.GetTranslation("FtpActionSettings", "PasswordTitle");
            var description = _translator.GetTranslation("FtpActionSettings", "PasswordDescription");

            var button      = retype ? PasswordMiddleButton.None : PasswordMiddleButton.Skip;
            var interaction = new PasswordInteraction(button, title, description, false)
            {
                Password  = job.Passwords.FtpPassword,
                IntroText = sb.ToString()
            };

            _interactionInvoker.Invoke(interaction);

            return(interaction);
        }
        public AddWalletPageViewModel(IScreen screen, WalletManager walletManager, BitcoinStore store, Network network) : base(screen)
        {
            Title = "Add Wallet";

            this.WhenAnyValue(x => x.WalletName)
            .Select(x => !string.IsNullOrWhiteSpace(x))
            .Subscribe(x => OptionsEnabled = x);

            RecoverWalletCommand = ReactiveCommand.Create(() => screen.Router.Navigate.Execute(new RecoveryPageViewModel(screen)));

            CreateWalletCommand = ReactiveCommand.CreateFromTask(
                async() =>
            {
                var result = await PasswordInteraction.Handle("").ToTask();

                if (result is { } password)
                {
                    var(km, mnemonic) = await Task.Run(
                        () =>
                    {
                        var walletGenerator = new WalletGenerator(walletManager.WalletDirectories.WalletsDir, network)
                        {
                            TipHeight = store.SmartHeaderChain.TipHeight
                        };
                        return(walletGenerator.GenerateWallet(WalletName, password));
                    });

                    await screen.Router.Navigate.Execute(
                        new RecoveryWordsViewModel(screen, km, mnemonic, walletManager));
                }
            });

            PasswordInteraction = new Interaction <string, string?>();
            PasswordInteraction.RegisterHandler(
                async interaction => interaction.SetOutput(await new EnterPasswordViewModel().ShowDialogAsync()));
        }
Esempio n. 20
0
        private void Registration_Click(object sender, RoutedEventArgs e)
        {
            string login = LoginBox.Text.ToLower();

            string password = PasswordBox.Password;

            string first_name  = First_NameBox.Text;
            string middle_name = Middle_NameBox.Text;
            string last_name   = Last_NameBox.Text;

            string phone = PhoneBox.Text;

            int    the_class = Int32.Parse(The_class_name.SelectedItem.ToString());
            string letter    = The_class_letter.SelectedValue.ToString();

            if (Position_name.SelectedIndex == -1)
            {
                MessageBox.Show("Выберите роль!");
                return;
            }

            if (login.Length == 0 || password.Length == 0 || first_name.Length == 0 || middle_name.Length == 0 || last_name.Length == 0)
            {
                MessageBox.Show("Пожалуйста, заполните все поля!", "Ошибка");
                return;
            }

            User user = new User
            {
                FirstName  = first_name,
                MiddleName = middle_name,
                LastName   = last_name,

                Login    = login,
                Password = PasswordInteraction.GetPasswordHash(password),

                Phone = phone,

                TheClassesId = unitOfWork.TheClasses.GetTheClassByNumber(the_class, letter)
            };


            if (UsersInteraction.RegisterRequestStatus(user) == false)
            {
                MessageBox.Show("Пользователь с таким логином уже зарегистрирован!", "Error");
                return;
            }

            if (Position_name.SelectedValue.ToString() == "Учитель")
            {
                int subject_id = Specialisation.SelectedIndex + 1;
                TeachersInteraction.Insert_Teacher(user, subject_id);
            }

            MessageBox.Show("Вы успешно зарегистрировались!", "Info");

            user = unitOfWork.Users.GetUserByName(first_name, last_name, middle_name);

            mainWindow.user = user;

            if (TeachersInteraction.IsTeacher(user))
            {
                mainWindow.Navigation.Navigate(new TeacherPage(mainWindow, TeachersInteraction.GetTeacherModel(user)));
            }
            else
            {
                mainWindow.Navigation.Navigate(new UserPage(mainWindow, user));
            }
        }