private User GetUser(string username) { using (var context = new WebAPIExamplesContext()) { return(context.Users.FirstOrDefault(u => u.Username == username)); } }
private bool ValidateUser(string username, string password, out User user) { using (var context = new WebAPIExamplesContext()) { user = context.Users.FirstOrDefault(u => u.Username == username && u.Status == UserStatus.Active); if (null == user) { return(false); } // Use bcrypt and compare the password // The salt is already contained in the hash bool validPassword = password == user.Password; return(validPassword); } }