summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordan <[email protected]>2023-05-12 09:47:57 -0400
committerdan <[email protected]>2023-05-12 09:47:57 -0400
commit4a0316c7970c59937d73744e482acaa524a6741b (patch)
tree0040151dab901fb0ead834a5a7c8b3719e849518
parent80e049f89cd388906b547aa264617a4a506b316a (diff)
download54-4a0316c7970c59937d73744e482acaa524a6741b.tar.gz
54-4a0316c7970c59937d73744e482acaa524a6741b.tar.bz2
54-4a0316c7970c59937d73744e482acaa524a6741b.zip
fix: hash passwords
-rw-r--r--main.scm7
-rw-r--r--makefile1
2 files changed, 4 insertions, 4 deletions
diff --git a/main.scm b/main.scm
index b269e23..a57d8c2 100644
--- a/main.scm
+++ b/main.scm
@@ -112,14 +112,13 @@
(define (parent-id p) (fifth p))
(define (children-count p) (sixth p))
-
-(define users (alist->hash-table '(("lawrence" . "pw") ("demo" . "pw") ("dan" . "pw"))))
+(define users (alist->hash-table `(("example" . ,(crypt "pw")))))
(define apikeys (make-hash-table))
(define (login username password)
- (let ([pw-in-db (hash-table-ref/default users username #f)])
- (and password (equal? password pw-in-db)
+ (let ([pw-hash-in-db (hash-table-ref/default users username #f)])
+ (and password (string=? (crypt password pw-hash-in-db) pw-hash-in-db)
(let ([apikey (number->string (pseudo-random-integer 340282366920938463463374607431768211455))])
(hash-table-set! apikeys apikey username)
apikey))))
diff --git a/makefile b/makefile
index 24791ff..b840280 100644
--- a/makefile
+++ b/makefile
@@ -6,6 +6,7 @@ build: ./main.scm build-cpp
# -C -Ilib/
chicken-csc -static ./main.scm \
-L -lsqlite3 \
+ -L -lcrypt \
-L lib/exif_wrapper.o \
-L /lib/libexiv2.so \
-L /usr/lib/libstdc++.so.6 \