Skip to content

Instantly share code, notes, and snippets.

@chadhs
Created July 26, 2018 21:49
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 chadhs/8798193e3b70b1c08c2427ad59f04f94 to your computer and use it in GitHub Desktop.
Save chadhs/8798193e3b70b1c08c2427ad59f04f94 to your computer and use it in GitHub Desktop.
(defn handle-auth-login [req]
(let [email (get-in req [:params :email])
password (get-in req [:params :password])
authfacts (auth.model/read-account-auth-facts db-url {:account-email email})
account-id (get authfacts :id)
passhash (get authfacts :password_hash)
hashcalc (hashers/check password passhash)
login-error (cond (nil? account-id) :account-id
(false? hashcalc) :password)]
(if (nil? login-error)
(do
(timbre/info (str "account authenticated successfully: " account-id " : " email))
(response/redirect "/lists"))
(do
(timbre/error (str "account authentication failure reason " login-error " " account-id " : " email))
{:status 200
:headers {"Content-Type" "text/html"}
:body (auth.view.login/login-page login-error)}))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment