Skip to content

Instantly share code, notes, and snippets.

Created October 20, 2013 13:57
What would you like to do?
(defn handle-register [username email pass1 pass2]
(if(has-values?[username email pass1 pass2])
(json {:resp "Please fill all fields."}))
(if(not(= pass1 pass2))
(json {:resp "Passwords dont match."}))
(if(not(nil?(db/get-user-by-username username)))
(json {:username "This username already exists."}))
(if (nil?(db/get-user email))
(db/add-user-record {:username username
:email email
:password (crypt/encrypt pass1)})
(let [user (db/get-user email)]
(session/put! :user user))
(redirect "/admin"))
(json {:email "This email already exists"})))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment