Exemplo n.º 1
0
        public void ChangePass(Account account)
        {
            var changeAccount = new Account();

            Console.WriteLine("Nhập vào mã tài khoản bạn muốn thay mật khẩu");
            changeAccount.AccountNumber = Console.ReadLine();
            Console.WriteLine("Nhập vào mật khẩu cũ : ");
            string oldPass = Console.ReadLine();
            bool   compare = _passwordHelper.ComparePassword(oldPass, account.Salt, account.PasswordHash);

            if (compare)
            {
                string newPass;
                while (true)
                {
                    Console.WriteLine("Nhập vào mật khẩu mới :");
                    newPass = Console.ReadLine();
                    if (newPass != oldPass)
                    {
                        break;
                    }
                    Console.WriteLine("Xin hãy chọn mật khẩu mới khác mật khẩu cũ");
                }
                changeAccount.Salt         = _passwordHelper.RandomString(5);
                changeAccount.PasswordHash = _passwordHelper.CreateMD5(newPass + account.Salt);
                _adminModel.ChangePassword(changeAccount);
            }
            Console.WriteLine("Sai mật khẩu");
            Console.WriteLine("Nhấn phím bất kỳ để xác nhận");
            Console.ReadKey();
        }
Exemplo n.º 2
0
        // 10. Thay doi mat khau
        public void PasswordChange()
        {
            Console.WriteLine("---- Thay đổi mật khẩu tài khoản ----");
            Console.WriteLine("Vui lòng nhập mật khẩu: ");
            var password = Console.ReadLine();

            Console.WriteLine("Vui lòng xác nhận lại mật khẩu: ");
            var confirmPassword = Console.ReadLine();

            if (password == confirmPassword)
            {
                _adminModel.ChangePassword(password);
            }
            else
            {
                Console.WriteLine("Xác nhận mật khẩu không khớp!");
            }
        }