// validateTatHeaders fetch user in db and check Password func validateTatHeaders(tatHeaders tatHeaders) (models.User, error) { user := models.User{} if tatHeaders.trustUsername != "" && tatHeaders.trustUsername != "null" { err := user.TrustUsername(tatHeaders.trustUsername) if err != nil { return user, fmt.Errorf("User %s does not exist. Please register before. Err:%s", tatHeaders.trustUsername, err.Error()) } } else { err := user.FindByUsernameAndPassword(tatHeaders.username, tatHeaders.password) if err != nil { return user, fmt.Errorf("Invalid Tat credentials for username %s, err:%s", tatHeaders.username, err.Error()) } } return user, nil }