blob: 3f7e8fa02b50cd61c6fb5e77614fd9502d2163e2 (
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
33
34
35
36
37
38
39
40
|
(in-package #:vampire)
(wknd:defendpoint login.html
:get :route "login"
:returns "text/html"
:handle (login-page))
(wknd:defendpoint login-user
:post :route "login"
:parameters
(name string)
(password string)
:properties
(user user)
:authenticate (authenticate-login-user name password)
:handle (wknd:endpoint-redirect 'home.html))
(defun authenticate-login-user (name password)
(do>
found-user :when= (user-with-name name)
:when (equal (user-pwhash found-user)
(hash-string password (user-pwsalt found-user)))
session := (db:with-transaction () (make-instance 'session :user found-user))
(wknd:set-cookie +session-cookie+ :value (key session))))
(defun login-page ()
(page (:title "V A M P I R E ~ LOGIN")
(:div (:h1 "I vant to suck your blood")
(:form :method "POST" :action (wknd:route-to 'login-user)
(:input :placeholder "Name" :name "name")
(:br)
(:input :placeholder "Password" :type "password" :name "password")
(:br)
(:button :type "submit" "Click to Login"))
(:a :href (wknd:route-to 'new-account.html)
"Become Undead"))))
|