       :else nil)))
 
 (defn- issuer-verified? [factory-url asr]
-  (when (and (string? factory-url) (map? asr))
+  (when (and (string? factory-url) (map? asr) (string/starts-with? (get asr :id "") factory-url))
     (try
       (let [badge (if (map? (:badge asr)) (:badge asr) (http/json-get (:badge asr)))
             issuer-url (if (map? (:issuer badge)) (get-in badge [:issuer :id]) (:issuer badge))

            (check-badge db-conn factory-url user-badge)
            (jdbc/execute! db-conn ["UPDATE user_badge SET last_checked = UNIX_TIMESTAMP() WHERE id = ?"
                              (:id user-badge)])
            (catch Throwable ex
              (log/error "check-badges failed")
              (log/error (.toString ex)))))


(defn- check-badges [db-conn factory-url]
  (log/info "check-badges: started working")
  (let [time-limit (+ (System/currentTimeMillis) (* 30 60 1000))
        sql "SELECT id, badge_id, assertion_url FROM user_badge
            WHERE assertion_url IS NOT NULL
            AND deleted = 0 AND revoked = 0 AND status = 'accepted'
            AND (expires_on IS NULL OR expires_on > UNIX_TIMESTAMP())
            ORDER BY last_checked LIMIT 1000"]
    (doseq [chunk (partition-all 5 (jdbc/query db-conn [sql]))]
      (when (> time-limit (System/currentTimeMillis))
        (doseq [user-badge chunk]
          (try
