Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (ns sql.users.password
- (:use [korma.core])
- (:require [cemerick.friend :as friend]
- (cemerick.friend [workflows :as workflows]
- [credentials :as creds])))
- (defentity passwords
- (pk :id) ;; By default "id"
- (table :passwords) ;; By default the name of the symbol
- (entity-fields :pw_user_id :pw_hash) ;; Default fields for selects
- (database mybg) ;; if none is specified the last defdb
- ;; will be used
- )
- (defn add [userid passwort]
- (let (hash (creds/hash-bcrypt passwort))
- (sql/with-connection mysql-db
- (sql/insert-records :passwords
- {:pw_user_id userid
- :pw_hash hash}))))
- (defn change [userid passwort]
- (let (hash (creds/hash-bcrypt passwort))
- (sql/with-connection mysql-db
- (sql/update-values :passwords
- [(str "pw_user_id = " userid)]
- {:pw_hash hash}))))
Add Comment
Please, Sign In to add comment