Пример #1
0
        }//METHOD Authenticate

        public User ForgotPasswordUpdate(User user, string password, string passwordToken)
        {
            if (!VerifyPasswordToken(passwordToken, user.IdUser))
            {
                throw new Exception("Password Token is not correct");
            }

            // validation
            if (string.IsNullOrWhiteSpace(password))
            {
                throw new Exception("Password is required");
            }

            byte[] passwordHash, passwordSalt;
            CreatePasswordHash(password, out passwordHash, out passwordSalt);

            user.PasswordHash    = passwordHash;
            user.PasswordSalt    = passwordSalt;
            user.IsAccountActive = true;

            _context.Users.Update(user);

            var tokenEntry = _context.PasswordTokens.SingleOrDefault(token => token.IdUser == user.IdUser);

            _context.Remove(tokenEntry);

            _context.SaveChanges();

            return(user);
        }
Пример #2
0
        public IActionResult DeleteCustomer(int id)
        {
            Customer currentCustomer = _context.Customer.SingleOrDefault(customer => customer.id == id);

            _context.Remove(currentCustomer);
            _context.SaveChanges();
            return(RedirectToAction("Customers"));
        }