Skip to content

Instantly share code, notes, and snippets.

@alioguzhan
Created October 20, 2013 13:57
Embed
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))
(do
(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