aboutsummaryrefslogtreecommitdiffhomepage
path: root/login.lisp
blob: 4776fe5fd70b4d07a063f35296d1fdf714d8b886 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
;;;; login.lisp

(in-package :vampire)

(defun login-page (body)
  (include-style body)
  (with-clog-create body
      (div ()
           (div ()
                (section (:h3 :content "LOGIN"))
                (form ()
                      (form-element (:text :bind name-input))
                      (br ())
                      (form-element (:password :bind pw-input))
                      (br ())
                      (button (:bind btn :content "Click here to log in"))))
           (div ()
                (:p ()
                    (:a (:link "/new-account" :content "Create an account")))))
    (setf (place-holder name-input) "Name"
          (place-holder pw-input) "Password")
    (set-on-click
     btn
     (thunk*
       (let ((user
               (login-user (value name-input) (value pw-input))))
         (if user
             (let ((session (make-session user)))
               (setf (session-key (window body)) (key session)
                     (url (location body)) "/home"))
             (alert (window body) "Error logging in.")))))))