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

(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

(ns crunsher.communication.auth
  (:require [ajax.core :refer [POST]]
            [crunsher.communication.utils :as com]
            [crunsher.config :as config]
            [crunsher.communication.main :as com]
            [crunsher.communication.utils :as clib]))

(defn success-login
  "Callback function when login was successful. Set attributes of user."
