aboutsummaryrefslogtreecommitdiffhomepage
path: root/model.lisp
diff options
context:
space:
mode:
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)