 (ns crunsher.communication.auth
   (:require [ajax.core :refer [POST]]
-            [goog.crypt.base64 :as gtfo]
             [crunsher.communication.utils :as com]
             [crunsher.config :as config]
-            [crunsher.debug :as debug]
-            [crunsher.utils.common :as lib]
             [crunsher.communication.main :as com]
-            [crunsher.communication.utils :as clib]
-            ))
+            [crunsher.communication.utils :as clib]))
 
 (defn success-login
   "Callback function when login was successful. Set attributes of user."


(defn ajax-login
  "Get cleaned data and send ajax request."
  [nickname password]
  (let [url (str (:base config/api) "login")]
    (POST (clib/make-url url)
          {:body            (clib/clj->json {:nickname nickname
                                            :password password})
           :handler         success-login
           :error-handler   com/error-handler
           :response-format :json


(defn login
  "Use login form data, validate it and send ajax request."
  [email password location]
  (when (and
          (pos? (count email))
          (pos? (count password))
          (pos? (count location)))
    (ajax-login email password location)))