Skip to content

Instantly share code, notes, and snippets.

Created April 30, 2014 23:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2bbbeb0d6e5c14faa404 to your computer and use it in GitHub Desktop.
Save anonymous/2bbbeb0d6e5c14faa404 to your computer and use it in GitHub Desktop.
(ns galacticdonut.routes.auth
(:require [compojure.core :refer :all]
[com.ashafa.clutch :as clutch]
[noir.session :as session]
[noir.response :as response]
[noir.validation :as vali]
[cemerick.friend :as friend]
[cemerick.friend [workflows :as workflows]
[credentials :as creds]]))
(defn authorize* [routes username pass])
(defn authorize [routes {:keys [username pass]}])
(defn valid? [username pass pass1]
(vali/rule (vali/has-value? username))
(vali/rule (vali/min-length? pass 5)
[:pass "Password must be at least 5 characters"])
(vali/rule (= pass pass1)
[:pass "Passwords don't match up"])
(not (vali/errors? :username :pass :pass1)))
(defn handle-registration
"Collect new users information to handle registration"
[id pass pass1]
(session/put! :username id)
(response/redirect))
(defroutes auth-routes
(GET "/register" [])
(POST "/register" [username pass pass1]
(handle-registration username pass pass1)))
(ns galacticdonut.handler
(:require [compojure.core :refer [defroutes routes]]
[ring.middleware.resource :refer [wrap-resource]]
[ring.middleware.file-info :refer [wrap-file-info]]
[hiccup.middleware :refer [wrap-base-url]]
[compojure.handler :as handler]
[compojure.route :as route]
[galacticdonut.routes.home :refer [home-routes]]
[galacticdonut.routes.auth :refer [auth-routes]]))
(defn init []
(println "galacticdonut is starting"))
(defn destroy []
(println "galacticdonut is shutting down"))
(defroutes app-routes
(route/resources "/")
(route/not-found "Not Found"))
(def app
(-> (routes home-routes auth-routes app-routes)
(handler/site)
(wrap-base-url)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment