Example #1
0
        public void UpdatePassword(object obj)
        {
            //gets password box values from command parameters on view
            var         pswBoxes       = obj as List <object>;
            PasswordBox pwdBox         = pswBoxes[0] as PasswordBox;
            PasswordBox pwdBoxRepeat   = pswBoxes[1] as PasswordBox;
            var         password       = pwdBox.Password;
            var         passwordRepeat = pwdBoxRepeat.Password;

            if (string.IsNullOrEmpty(password))
            {
                MessageBox.Show("Missing password!");
            }

            else if (password != passwordRepeat)
            {
                MessageBox.Show("Passwords don't match!");
            }

            else
            {
                //hashing data
                var hashSalt = HashSalt.GenerateSaltedHash(64, password);
                Queries.UpdatePassword(UserLogin, hashSalt);
            }
        }
Example #2
0
        /// <summary>
        /// creates user account bassed on credentials provided in create account view
        /// </summary>
        public bool CreateAccount(object obj)
        {
            //gets password box values from command parameters on view
            var         pswBoxes     = obj as List <object>;
            PasswordBox pwdBox       = pswBoxes[0] as PasswordBox;
            PasswordBox pwdBoxRepeat = pswBoxes[1] as PasswordBox;

            var password       = pwdBox.Password;
            var passwordRepeat = pwdBoxRepeat.Password;

            if (string.IsNullOrEmpty(password))
            {
                MessageBox.Show("Missing password!");
            }

            else if (password != passwordRepeat)
            {
                MessageBox.Show("Passwords don't match!");
            }

            else
            {
                //hashing data
                var hashSalt = HashSalt.GenerateSaltedHash(64, password);

                AccountModel account = new AccountModel
                {
                    UserLogin      = UserLogin.Trim(),
                    UserBirthday   = UserBirthday,
                    UserHeight     = UserHeight,
                    UserName       = UserName,
                    UserMail       = UserMail,
                    UserGender     = UserGender,
                    SecretQuestion = SelectedItem.Symbol,
                    SecretAnswer   = SecretAnswer,
                    HashSalt       = hashSalt
                };

                Queries.CreateUserAccount(account);
            }


            return(true);
        }