예제 #1
0
        private void OkCommandMethod()
        {
            if (String.IsNullOrEmpty(Password) || String.IsNullOrEmpty(Login))
            {
                MessageBox.Show("Введите логин и пароль!", "Вход", MessageBoxButton.OK, MessageBoxImage.Stop);
                return;
            }

            Models.User CurrUser = Users.FirstOrDefault(o => o.Login == Login);
            if (CurrUser == null)
            {
                MessageBox.Show("Пользователь с таким именем не найден!", "Вход", MessageBoxButton.OK, MessageBoxImage.Stop);
                return;
            }

            byte[] pass_bytes         = Encoding.UTF8.GetBytes(Password);
            byte[] pass_salt          = Encoding.UTF8.GetBytes(CurrUser.PasswordSalt);
            byte[] hash               = Helpers.PasswordHelper.GenerateSaltedHash(pass_bytes, pass_salt);
            string hash_str_for_check = Convert.ToBase64String(hash);

            if (hash_str_for_check == CurrUser.PasswordHash)
            {
                Application.Current.Properties["CurrentUser"] = CurrUser;
                Views.StartWindow startWindow = new Views.StartWindow();
                startWindow.Show();
                CurrentLoginWindow.Close();
            }
            else
            {
                MessageBox.Show("Неправильный пароль!", "Вход", MessageBoxButton.OK, MessageBoxImage.Stop);
            }
        }
 private void Start()
 {
     Views.StartWindow startWindow = new Views.StartWindow();
     startWindow.Show();
     _window.Close();
 }