Beispiel #1
0
        private void ChangePassword_Click(object sender, RoutedEventArgs e)
        {
            string oldPass  = Hesher.MD5Hash(TB_OldPassword.Password);
            string newPass1 = TB_NewPassword1.Password;
            string newPass2 = TB_NewPassword2.Password;

            if (oldPass != App.Repository.Users.FirstOrDefault().Password)
            {
                ValPasswordWrong.Visibility = Visibility.Visible;
                return;
            }
            else
            {
                ValPasswordWrong.Visibility = Visibility.Collapsed;
            }

            if (newPass1 != newPass2)
            {
                ValPasswordMach.Visibility = Visibility.Visible;
                return;
            }
            else
            {
                ValPasswordMach.Visibility = Visibility.Collapsed;
            }

            string password = Hesher.MD5Hash(TB_NewPassword1.Password);

            App.Repository.ChangePassword(password);
            App.Frame.Navigate(new StartUpPage());
        }
        private void Authorize_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string    login      = TB_Login.Text;
                string    password   = Hesher.MD5Hash(TB_Password.Password);
                bool      userExist  = false;
                ModelUser findedUser = null;

                foreach (ModelUser user in App.Repository.Users)
                {
                    if (login == user.Login)
                    {
                        userExist  = true;
                        findedUser = user;
                    }
                }

                if (!userExist)
                {
                    ShowValidMessageLogin();
                    return;
                }

                if (password == findedUser.Password)
                {
                    if (_close)
                    {
                        Application.Current.Shutdown();
                    }
                    else
                    {
                        App.IsAuthorized = true;
                        var entry = App.Frame.RemoveBackEntry();

                        while (entry != null)
                        {
                            entry = App.Frame.RemoveBackEntry();
                        }

                        App.Frame.Navigate(new PageFunction <string>()
                        {
                            RemoveFromJournal = true
                        });
                        App.AuthorizedUser = findedUser;
                        App.Frame.Navigate(new StartUpPage());
                    }
                }
                else
                {
                    ShowValidMessagePassword();
                    return;
                }
            }
            catch (Exception ex)
            {
                App.SendException(ex);
            }
        }