Created
November 13, 2012 18:15
-
-
Save Licenser/4067414 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns net.project-fifo.wiggle.views.login | |
(:require [net.project-fifo.wiggle.views.common :as common] | |
[noir.content.getting-started] | |
[noir.cookies :as cookies] | |
[net.project-fifo.libsnarl.user :as user]) | |
(:use [noir.core :only [defpage defpartial]] | |
[hiccup.core :only [html]])) | |
(defpartial render-login [] | |
(common/layout | |
[:div {:class "row-fluid"} | |
[:div {:class "span4 offset4"} | |
[:form {:method :post} | |
[:fieldset | |
[:legend "Login"] | |
[:label "Login"] | |
[:input {:name :login :type :text :placeholder "Login..."}] | |
[:label "Password"] | |
[:input {:name :password | |
:type :password :placeholder "Password..."}] [:br] | |
[:button {:type "submit" :class "btn"} "Submit"]]]]])) | |
(defpage "/login" [] | |
(render-login)) | |
(defpage [:post "/login"] {:keys [login password]} | |
(let [token (user/auth {:name "127.0.0.1" :port 4200} login password)] | |
(if (= token :not_found) | |
(render-login) | |
(let [[_ token] token] | |
(prn token) | |
(cookies/put! :token token) | |
(common/layout "login!"))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment