From e5947122bae1115b024be354ace6885cb360037e Mon Sep 17 00:00:00 2001 From: ckonstanski Date: Tue, 22 Dec 2020 09:19:28 -0700 Subject: updated to latest bootstrap --- service/auth-service.lisp | 6 +++--- service/inetorg-delete-service.lisp | 8 ++++---- service/inetorg-modify-service.lisp | 11 +++++++---- service/inetorg-view-service.lisp | 6 +++--- service/login-service.lisp | 2 +- service/menu-service.lisp | 32 ++++++++++++++++---------------- service/rest-service.lisp | 10 ++++------ 7 files changed, 38 insertions(+), 37 deletions(-) (limited to 'service') diff --git a/service/auth-service.lisp b/service/auth-service.lisp index 2cdc7bf..24556b7 100644 --- a/service/auth-service.lisp +++ b/service/auth-service.lisp @@ -9,11 +9,11 @@ (defmethod initialize-instance :after ((auth-service auth-service) &key) (when (not (string= (session-value :permissions) "admin")) - (setf (location auth-service) "home") + (setf (location auth-service) "/home") (setf (errormsg auth-service) "You are not authorized to access this resource."))) -(defmacro with-auth ((instance form-class) &body body) - `(let ((,instance (make-instance ',form-class))) +(defmacro with-auth ((instance auth-service) &body body) + `(let ((,instance (make-instance ',auth-service))) (when (null (errormsg ,instance)) ,@body) (objects-to-json `(,,instance)))) diff --git a/service/inetorg-delete-service.lisp b/service/inetorg-delete-service.lisp index 1bcac65..8756f64 100644 --- a/service/inetorg-delete-service.lisp +++ b/service/inetorg-delete-service.lisp @@ -3,7 +3,7 @@ (in-package #:ldapadmin) -(defclass inetorg-delete (auth-service) +(defclass inetorg-delete-service (auth-service) ((cn :initarg :cn :initform nil :accessor cn) @@ -13,15 +13,15 @@ (:documentation "")) (defun inetorg-delete-json (cn) - (with-auth (instance inetorg-delete) + (with-auth (instance inetorg-delete-service) (setf (cn instance) cn))) -(defclass inetorg-delete-submit (auth-service) +(defclass inetorg-delete-submit-service (auth-service) () (:documentation "")) (defun inetorg-delete-submit-json (cn) - (with-auth (instance inetorg-delete-submit) + (with-auth (instance inetorg-delete-submit-service) (with-ldap (ldap) (let ((ldap-user (get-ldap-user ldap cn))) (delete-ldap-user ldap-user ldap) diff --git a/service/inetorg-modify-service.lisp b/service/inetorg-modify-service.lisp index 293c43b..61e7c16 100644 --- a/service/inetorg-modify-service.lisp +++ b/service/inetorg-modify-service.lisp @@ -7,6 +7,9 @@ ((form :initarg :form :initform nil :accessor form) + (ldap-user-values :initarg :ldap-user-values + :initform nil + :accessor ldap-user-values) (title :initarg :title :initform nil :accessor title) @@ -19,7 +22,7 @@ (setf (form inetorg-modify-service) (make-form "inetorg-modify-form" nil t - '((:name "modify-givenname" :label "givenName" :field-type "text" :value ) + `((:name "modify-givenname" :label "givenName" :field-type "text") (:name "modify-sn" :label "sn" :field-type "text") (:name "modify-mail" :label "mail" :field-type "text") (:name "modify-postaladdress" :label "postalAddress" :field-type "text") @@ -29,21 +32,21 @@ (:name "modify-telephonenumber" :label "telephoneNumber" :field-type "text") (:name "modify-mobile" :label "mobile" :field-type "text") (:name "modify-businesscategory" :label "businessCategory" :field-type "text") - (:label "Modify InetOrg Entry" :field-type "button"))) + (:label "Modify InetOrg Entry" :field-type "button" :onclick "on_inetorg_modify_submit_clicked()"))))) (defun inetorg-modify-json (cn) (with-auth (instance inetorg-modify-service) (with-ldap (ldap) (setf (ldap-user-values instance) (get-ldap-user ldap cn))))) -(defclass inetorg-modify-submit (auth-service) +(defclass inetorg-modify-submit-service (auth-service) ((location-p :initarg :location-p :initform nil :accessor location-p)) (:documentation "")) (defun inetorg-modify-submit-json (givenname sn mail postaladdress postalcode st l telephonenumber mobile businesscategory) - (with-auth (instance inetorg-modify-submit) + (with-auth (instance inetorg-modify-submit-service) (with-ldap (ldap) (let ((ldap-user (make-instance 'ldap-user :givenname givenname diff --git a/service/inetorg-view-service.lisp b/service/inetorg-view-service.lisp index 5cbd0c6..370fdc6 100644 --- a/service/inetorg-view-service.lisp +++ b/service/inetorg-view-service.lisp @@ -3,14 +3,14 @@ (in-package #:ldapadmin) -(defclass inetorg-view (auth-service) +(defclass inetorg-view-service (auth-service) ((title :initarg :title :initform nil :accessor title)) (:documentation "")) (defun inetorg-view-json () - (with-auth (instance inetorg-view) + (with-auth (instance inetorg-view-service) (setf (title instance) "Use the form to filter the InetOrg results."))) (defclass inetorg-view-search-service (auth-service) @@ -45,7 +45,7 @@ (with-auth (instance inetorg-view-search-service) nil)) -(defclass inetorg-view-results (auth-service) +(defclass inetorg-view-results-service (auth-service) ((results :initarg :results :initform nil :accessor results) diff --git a/service/login-service.lisp b/service/login-service.lisp index 8de0ec5..7007327 100644 --- a/service/login-service.lisp +++ b/service/login-service.lisp @@ -35,7 +35,7 @@ (setf (message login-authenticate-service) "Successfully logged in.") (setf (errormsg login-authenticate-service) "Login failed."))) -(defun login-authenticate-json (username pwd) +(defun login-authenticate-json (dn password) (let ((auth-result nil)) (when (check-ldap-password (ldap *webapp*) dn password) (setf (session-value :permissions) "admin") diff --git a/service/menu-service.lisp b/service/menu-service.lisp index 25cad07..8ee9c25 100644 --- a/service/menu-service.lisp +++ b/service/menu-service.lisp @@ -30,26 +30,26 @@ :accessor children)) (:documentation "")) -(defclass menu (base-service) +(defclass menu-service (base-service) ((menuitems :initarg :menuitems :initform nil :accessor menuitems)) (:documentation "")) -(defmethod initialize-instance :after ((menu menu) &key) - (setf (menuitems menu) - (mapcar (lambda (x) - (make-instance 'menuitem - :id (getf x :id) - :label (getf x :label) - :url (getf x :url) - :handler (getf x :handler))) - (remove-if 'null (mapcar (lambda (x) - (when (find-if (lambda (y) - (string= (getf x :permission) y)) - `("t" ,(session-value :permissions))) - x)) - *menu-config*))))) +(defmethod initialize-instance :after ((menu-service menu-service) &key) + (setf (menuitems menu-service) + (mapcar (lambda (x) + (make-instance 'menuitem + :id (getf x :id) + :label (getf x :label) + :url (getf x :url) + :handler (getf x :handler))) + (remove-if 'null (mapcar (lambda (x) + (when (find-if (lambda (y) + (string= (getf x :permission) y)) + `("t" ,(session-value :permissions))) + x)) + *menu-config*))))) (defun menu-json () - (objects-to-json `(,(make-instance 'menu)))) + (objects-to-json `(,(make-instance 'menu-service)))) diff --git a/service/rest-service.lisp b/service/rest-service.lisp index b34817f..3c122f7 100644 --- a/service/rest-service.lisp +++ b/service/rest-service.lisp @@ -20,12 +20,10 @@ (defmethod initialize-instance :after ((rest-service rest-service) &key) (when (and (location-p rest-service) (null (location rest-service))) - (setf (location rest-service) (type-to-path rest-service)) - (setf (session-value :location) (location rest-service)))) + (setf (location rest-service) (type-to-path rest-service)))) -(defun location-json () - (let ((location (if (session-value :location) (session-value :location) "/home"))) - (format nil "{\"location\":\"~a\"}" location))) +(defun location-json (&optional (location "/home")) + (format nil "{\"location\":\"~a\"}" location)) (defun type-to-path (rest-type) - (concatenate 'string "/" (ppcre:regex-replace "-" (string-downcase (type-of rest-type)) "/"))) + (concatenate 'string "/" (ppcre:regex-replace "-service" (string-downcase (type-of rest-type)) "/"))) -- cgit v1.3