From 0b21729661ed1905eb886b1eba6f8b062305c9a3 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Thu, 27 Oct 2022 07:52:50 -0500 Subject: Modify+Add: Added pw hashing stuff to user. Add login file. --- model.lisp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'model.lisp') 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) -- cgit v1.2.3