aboutsummaryrefslogtreecommitdiffhomepage
path: root/model.lisp
diff options
context:
space:
mode:
authorColin Okay <colin@cicadas.surf>2022-10-27 07:52:50 -0500
committerColin Okay <colin@cicadas.surf>2022-10-27 07:52:50 -0500
commit0b21729661ed1905eb886b1eba6f8b062305c9a3 (patch)
treec3071c5238d1dc174bfaf42ccad59a88d710f043 /model.lisp
parent52c0408569a0b1de932d52e71fee5fb0163782e2 (diff)
Modify+Add: Added pw hashing stuff to user. Add login file.
Diffstat (limited to 'model.lisp')
-rw-r--r--model.lisp12
1 files changed, 10 insertions, 2 deletions
diff --git a/model.lisp b/model.lisp
index 246e27f..b88bd91 100644
--- a/model.lisp
+++ b/model.lisp
@@ -9,9 +9,11 @@
:index-reader object-with-key)))
(defclass/bknr user (keyed)
- ((name :with :std "")
+ ((name :with
+ :index-type string-unique-index
+ :index-reader user-with-name)
(playlists :with :std (list))
- (pw pwhash :with)))
+ (pwsalt pwhash :with)))
(defclass/bknr playlist (keyed)
((title :with :std (default-name "playlist"))
@@ -36,6 +38,12 @@
(when (typep obj 'user)
obj)))
+(defun login-user (username password)
+ (when-let (user (user-with-name username))
+ (with-slots (pwhash pwsalt) user
+ (when (equalp pwhash (hash-string password pwsalt))
+ user))))
+
(defun playlist-duration (pl)
(reduce #'+
(playlist-tracks pl)