summaryrefslogtreecommitdiff
path: root/lisp/sql/user.lisp
diff options
context:
space:
mode:
authorckonstanski <carlos.konstanski@olo.com>2024-05-25 18:03:25 -0600
committerckonstanski <carlos.konstanski@olo.com>2024-05-25 18:03:25 -0600
commitb8423f4d05c75094b7b9d09c6f0bb353acc9be1c (patch)
tree3732f71f84191b26f038130c2220fb502d738251 /lisp/sql/user.lisp
initial commit
Diffstat (limited to 'lisp/sql/user.lisp')
-rw-r--r--lisp/sql/user.lisp50
1 files changed, 50 insertions, 0 deletions
diff --git a/lisp/sql/user.lisp b/lisp/sql/user.lisp
new file mode 100644
index 0000000..a181ff4
--- /dev/null
+++ b/lisp/sql/user.lisp
@@ -0,0 +1,50 @@
+;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+(declaim (optimize (speed 0) (safety 3) (debug 3)))
+
+(in-package :woodriverlessons)
+
+(defclass user (org-ckons-session::session-object postgres-record)
+ ((id :initarg :id
+ :initform nil
+ :accessor id)
+ (username :initarg :username
+ :initform nil
+ :accessor username)
+ (pwd :initarg :pwd
+ :initform nil
+ :accessor pwd)
+ (first_name :initarg :first_name
+ :initform nil
+ :accessor first_name)
+ (last_name :initarg :last_name
+ :initform nil
+ :accessor last_name)
+ (email :initarg :email
+ :initform nil
+ :accessor email)
+ (phone :initarg :phone
+ :initform nil
+ :accessor phone)
+ (active :initarg :active
+ :initform nil
+ :accessor active)
+ (created :initarg :created
+ :initform nil)
+ (*table :initform "auth.users")
+ (*where-expression :initform "id = ~a")
+ (org-ckons-session::*session-key :initform "user"))
+ (:documentation "Holds the data for a user record."))
+
+(defmethod created ((user user))
+ (slot-value user 'created))
+
+(defmethod (setf created) (value (user user))
+ (handler-case
+ (setf (slot-value user 'created) (simple-date-to-date value))
+ (error (e)
+ (declare (ignore e))
+ (setf (slot-value user 'created) nil))))
+
+(defmethod sanitize-json ((user user))
+ (setf (pwd user) nil)
+ (call-next-method))