diff options
| author | ckonstanski <kostcarl@isu.edu> | 2026-09-06 22:04:28 -0600 |
|---|---|---|
| committer | ckonstanski <kostcarl@isu.edu> | 2026-09-06 22:04:28 -0600 |
| commit | e774d11af63764a7457d842ecd74b30a183fa71e (patch) | |
| tree | 7e0237cf69236ca14a7ad954dc083355b8f30e4a /lisp/service/profile-service.lisp | |
| parent | beb0bed0b615ebcfdc0415cc9d7aff656964c427 (diff) | |
Diffstat (limited to 'lisp/service/profile-service.lisp')
| -rw-r--r-- | lisp/service/profile-service.lisp | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/lisp/service/profile-service.lisp b/lisp/service/profile-service.lisp index 256d599..e8b68de 100644 --- a/lisp/service/profile-service.lisp +++ b/lisp/service/profile-service.lisp @@ -3,22 +3,18 @@ (in-package :bogenherr) -(defclass profile-service (auth-service user) +(defclass profile-service (auth-service) ((title :initarg :title :initform nil :accessor title)) (:documentation "")) -(defun profile-json () - (with-auth (instance profile-service "profile-modify") - (setf (title instance) "Profile") - (sanitize-rest-json instance))) - -(defun profile-view-json () - (with-auth (instance profile-service "profile-modify") - (let ((user (get-user))) - (copy-from-record instance user)) - (sanitize-rest-json instance))) +(defclass profile/view-service (profile-service) + ((items :initarg items + :initform nil + :accessor items) + (location-p :initform nil)) + (:documentation "")) (defclass profile/modify-service (profile-service) ((form :initarg :form @@ -27,10 +23,22 @@ (location-p :initform nil)) (:documentation "")) +(defun profile-json () + (with-auth (instance profile-service "profile-modify") + (setf (title instance) "Profile"))) + +(defun profile-view-json () + (with-auth (instance profile/view-service "profile-modify") + (let ((user (get-user))) + (setf (items instance) `(,user))) + (sanitize-rest-json instance) + (loop for item in (items instance) + do (sanitize-json item)))) + (defun profile-modify-json () (with-auth (instance profile/modify-service "profile-modify") (let ((user (get-user))) - (sanitize-rest-json instance) + (sanitize-json user) (setf (title instance) "Profile - Modify") (setf (form instance) (make-form "profile-modify-form" nil @@ -54,8 +62,12 @@ (intersection `(,x) '(id))) (sb-introspect:function-lambda-list #'profile-modify-submit-json)) do (setf (slot-value user param) (symbol-value param))) - (copy-from-record instance user) (update-user auth-pkg user) (set-user user) - (setf (session-value :message) "Profile saved successfully.")) - (setf (session-value :errormsg) "An error occured.")))))) + (setf (message instance) "Profile saved successfully.")) + (setf (errormsg instance) "An error occured.")))))) + +(define-endpoint ("/profile" :method :get) () profile-json) +(define-endpoint ("/profile/view" :method :get) () profile-view-json) +(define-endpoint ("/profile/modify" :method :post) () profile-modify-json) +(define-endpoint ("/profile/modify/submit" :method :post) (&post (id :parameter-type 'integer) (username :parameter-type 'string) (first_name :parameter-type 'string) (last_name :parameter-type 'string) (email :parameter-type 'string) (phone :parameter-type 'string)) profile-modify-submit-json id username first_name last_name email phone) |
