          logged-in?   (and stored-token (not (token/expired? stored-token)))
          path         (get-in cofx [:location :path])
          auth-route?  (routes/auth-route? path)]
-     ;; FIXME this conditions are complex and partially overlapping
-     ;; Try to separate in orthogonal events
      (cond
        (and auth-route? logged-in?)
        {:db         db/default-db

                     [:user-load {:access_token stored-token}]]}

       (and (not auth-route?) (not logged-in?))
       {:db         db/default-db
        :dispatch-n [[:navigate :login]
                     [:country-detect]]}

       (github-callback? path)
       {:db         db/default-db
        :dispatch-n [[:github-code-submit]
                     [:country-detect]]}

       (and stored-token (token/expired? stored-token))
       {:db                 expired-db
        :remove-local-store "access_token"
        :dispatch           [:country-detect]}

       stored-token
       {:db       db/default-db
        :dispatch [:user-load {:access_token stored-token}]}

       :else
       {:db       db/default-db
        :dispatch [:country-detect]}))))

(defn- basic-auth-header
  [user password]

            [bouncer.validators :as validators]
            [holiday-ping-ui.db :as db]
            [holiday-ping-ui.routes :as routes]
            [holiday-ping-ui.common.events :as events]
            [holiday-ping-ui.auth.token :as token]))

;;; AUTH EVENTS
