blob: af029475ab1fc722fd5459aa34509ee19499b0fd (
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
|
(in-package #:vampire)
(wknd:defendpoint create.session
:post :to "login"
:parameters
(name string)
(password string)
:properties
(user user)
:authenticate (authenticate-user-login name password)
:handle (wknd:endpoint-redirect 'home.html))
(defun authenticate-user-login (name password)
(do>
found-user :when= (user-with-name name)
(print found-user)
:when (equal (user-pwhash found-user)
(hash-string password (user-pwsalt found-user)))
session := (db:with-transaction () (make-instance 'session :user found-user))
(print session)
(wknd:set-cookie +session-cookie+ :value (key session))))
(wknd:defendpoint destroy.session
:using user-known
:post :to "logout"
:handle (do>
session := (object-with-key (wknd:get-cookie +session-cookie+))
(db:delete-object session)
(wknd:set-cookie +session-cookie+ :value nil)
(wknd:endpoint-redirect 'login.html)))
|