Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactored new-user #17

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions src/clauth/user.clj
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,10 @@

(defn new-user
"Create new user record"
([attrs] ; Swiss army constructor. There must be a better way.
(if attrs
(if (:encrypt-password attrs)
(assoc (dissoc attrs :encrypt-password)
:password (bcrypt (:encrypt-password attrs)))
attrs)))

([login password] (new-user login password nil nil))
([login password name url] (new-user { :login login :encrypt-password password :name name :url url})))
([attrs]
attrs)
([login password & [name url]]
{:login login :password (bcrypt password) :name name :url url}))

(defn reset-user-store!
"mainly for used in testing. Clears out all users."
Expand All @@ -51,9 +46,7 @@
"create a unique user and store it in the user store"
([attrs]
(store-user (new-user attrs)))
([login password] (register-user login password nil nil))
([login password name url]
(register-user (new-user login password name url))))
([login password & [name url]] (register-user (new-user login password name url))))

(defn authenticate-user
"authenticate user application using login and password"
Expand Down