コード例 #1
0
ファイル: AdminAccountService.cs プロジェクト: anhtrinhh/Ars
        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);
        }