예제 #1
0
        public async Task <AdminAccount> InsertAdmin(AdminAccount admin)
        {
            string salt = AppUtils.CreateRandomSalt();

            admin.AdminPassword = AppUtils.HashString(admin.AdminPassword, salt);
            admin.AdminId       = AppUtils.CreateRandomString(null, 10);
            return(await _repository.InsertAdmin(admin));
        }
예제 #2
0
        public async Task <bool> UpdateCustomerPassword(string customerNo, string customerPassword)
        {
            string salt = AppUtils.CreateRandomSalt();

            customerPassword = AppUtils.HashString(customerPassword, salt);
            bool success = await _repository.UpdateCustomerPassword(customerNo, customerPassword, salt);

            if (success)
            {
                return(true);
            }
            return(false);
        }
예제 #3
0
        public async Task <bool> ChangeCustomerPassword(string customerNo, string customerPassword, string currentPassword)
        {
            var customer = await GetCustomerByCustomerNo(customerNo);

            string hashCurrentPassword = AppUtils.HashString(currentPassword, customer.Salt);

            if (customer.CustomerPassword != hashCurrentPassword)
            {
                return(false);
            }
            string salt = AppUtils.CreateRandomSalt();

            customerPassword = AppUtils.HashString(customerPassword, salt);
            bool success = await _repository.UpdateCustomerPassword(customerNo, customerPassword, salt);

            if (success)
            {
                return(true);
            }
            return(false);
        }