 
 (def SESSION_COOKIE "metabase.SESSION_ID")
 (def SESSION_HEADER "x-metabase-session")
+
+(def response-unauthentic {:status 401 :body "Unauthenticated"})
 
 
 (defn wrap-sessionid

   NOTE: we are purposely not associating the full current user object here so that we can be modular."
  [handler]
  (fn [{:keys [metabase-sessionid] :as request}]
    (if-let [session (sel :one Session :id metabase-sessionid)]
      ;; TODO - enforce session expiration
      ;; TODO - validate user is_active?
      (handler (assoc request :metabase-userid (:user_id session)))
      {:status 401 :body "Unauthenticated"})))


(defmacro sel-current-user [current-user-id]

(ns metabase.middleware.auth
  "Middleware for dealing with authentication and session management."
  (:require [korma.core :as korma]
            [metabase.config :as config]
            [metabase.db :refer [sel]]
            [metabase.api.common :refer [*current-user* *current-user-id*]]
            (metabase.models [session :refer [Session]]
