Initial commit.
[microbotany.git] / register.scm
1 ;; Register a new user
2 ;;
3
4 (lambda (uri)
5   (import (chicken file)
6           uri-common simple-sha1)
7   (for-each eval (with-input-from-file "garden.scm" read-list))
8   (let ((query (uri-query uri)))
9     (if (null? query)
10         (serve-query "User name")
11         (let* ((username (symbol->string (caar query)))
12                (hash (string->sha1sum (conc username
13                                             (number->string (pseudo-random-integer 10000))))))
14           (with-output-to-file (conc "accounts/" hash)
15             (lambda ()
16               (write (make-garden username))))
17           (redirect-permanent (update-uri uri path: '(/ "microbotany" "view.scm")
18                                               query: `((,hash . #t))))))))
19                     
20                             
21
22