diff options
author | dan <[email protected]> | 2023-05-12 09:47:57 -0400 |
---|---|---|
committer | dan <[email protected]> | 2023-05-12 09:47:57 -0400 |
commit | 4a0316c7970c59937d73744e482acaa524a6741b (patch) | |
tree | 0040151dab901fb0ead834a5a7c8b3719e849518 | |
parent | 80e049f89cd388906b547aa264617a4a506b316a (diff) | |
download | 54-4a0316c7970c59937d73744e482acaa524a6741b.tar.gz 54-4a0316c7970c59937d73744e482acaa524a6741b.tar.bz2 54-4a0316c7970c59937d73744e482acaa524a6741b.zip |
fix: hash passwords
-rw-r--r-- | main.scm | 7 | ||||
-rw-r--r-- | makefile | 1 |
2 files changed, 4 insertions, 4 deletions
@@ -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)))) @@ -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 \ |