summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorckonstanski <ckonstanski@pippiandcarlos.com>2020-12-21 08:59:56 -0700
committerckonstanski <ckonstanski@pippiandcarlos.com>2020-12-21 08:59:56 -0700
commit0ed1cba1b39daaf8eef693233f081b455c88dece (patch)
tree0322ba1444ef724d4613e3c26ed2679e71bf1882 /service
parentbac1df6134eee78b79810d13c71a2b22b4739a12 (diff)
stuff
Diffstat (limited to 'service')
-rw-r--r--service/auth-service.lisp2
-rw-r--r--service/base-service.lisp2
-rw-r--r--service/generic-form.lisp72
-rw-r--r--service/home-service.lisp18
-rw-r--r--service/home.lisp18
-rw-r--r--service/inetorg-add-service.lisp57
-rw-r--r--service/inetorg-add.lisp56
-rw-r--r--service/inetorg-delete-service.lisp (renamed from service/inetorg-delete.lisp)6
-rw-r--r--service/inetorg-modify-service.lisp60
-rw-r--r--service/inetorg-modify.lisp60
-rw-r--r--service/inetorg-view-service.lisp72
-rw-r--r--service/inetorg-view.lisp72
-rw-r--r--service/login-authenticate.lisp24
-rw-r--r--service/login-service.lisp43
-rw-r--r--service/login.lisp18
-rw-r--r--service/logout-service.lisp17
-rw-r--r--service/logout.lisp19
-rw-r--r--service/menu-service.lisp (renamed from service/menu.lisp)2
-rw-r--r--service/rest-service.lisp2
19 files changed, 324 insertions, 296 deletions
diff --git a/service/auth-service.lisp b/service/auth-service.lisp
index 0d0e8a0..2cdc7bf 100644
--- a/service/auth-service.lisp
+++ b/service/auth-service.lisp
@@ -3,8 +3,6 @@
(in-package #:ldapadmin)
-;; ========================================================================== ;;
-
(defclass auth-service (rest-service)
()
(:documentation ""))
diff --git a/service/base-service.lisp b/service/base-service.lisp
index 0f65b82..bc110a3 100644
--- a/service/base-service.lisp
+++ b/service/base-service.lisp
@@ -3,8 +3,6 @@
(in-package #:ldapadmin)
-;; ========================================================================== ;;
-
(defclass base-service ()
()
(:documentation ""))
diff --git a/service/generic-form.lisp b/service/generic-form.lisp
index 1fb9867..e48d653 100644
--- a/service/generic-form.lisp
+++ b/service/generic-form.lisp
@@ -3,9 +3,7 @@
(in-package #:ldapadmin)
-;; ========================================================================== ;;
-
-(defclass generic-form (rest-service)
+(defclass generic-form (base-service)
((name :initarg :name
:initform nil
:accessor name)
@@ -15,6 +13,9 @@
(action :initarg :action
:initform nil
:accessor action)
+ (required-p :initarg :required-p
+ :initform nil
+ :accessor required-p)
(form-fields :initarg :form-fields
:initform nil
:accessor form-fields))
@@ -27,19 +28,60 @@
(label :initarg :label
:initform nil
:accessor label)
+ (value :initarg :value
+ :initform nil
+ :accessor value)
+ (checked :initarg :checked
+ :initform nil
+ :accessor checked)
(field-type :initarg :field-type
:initform nil
- :accessor field-type))
+ :accessor field-type)
+ (required :initarg :required
+ :initform nil
+ :accessor required)
+ (dismiss :initarg :dismiss
+ :initform nil
+ :accessor dismiss)
+ (options :initarg :options
+ :initform nil
+ :accessor options)
+ (onclick :initarg :onclick
+ :initform nil
+ :accessor onclick)
+ (onchange :initarg :onchange
+ :initform nil
+ :accessor onchange))
+ (:documentation ""))
+
+(defclass option (base-service)
+ ((label :initarg :label
+ :initform nil
+ :accessor label)
+ (value :initarg :value
+ :initform nil
+ :accessor value))
(:documentation ""))
-(defmacro define-generic-form-constructor ((form-class name action) fields)
- `(defmethod initialize-instance :after ((,form-class ,form-class) &key)
- (setf (name ,form-class) ,name)
- (setf (action ,form-class) ,action)
- (setf (form-fields ,form-class)
- (mapcar (lambda (form)
- (make-instance 'form-field
- :name (getf form :name)
- :label (getf form :label)
- :field-type (getf form :field-type)))
- ,fields))))
+(defun make-form (name action required-p fields)
+ (make-instance 'generic-form
+ :name name
+ :action action
+ :required-p required-p
+ :form-fields (mapcar (lambda (field)
+ (make-instance 'form-field
+ :name (getf field :name)
+ :label (getf field :label)
+ :value (getf field :value)
+ :checked (getf field :checked)
+ :field-type (getf field :field-type)
+ :required (getf field :required)
+ :dismiss (getf field :dismiss)
+ :options (mapcar (lambda (option)
+ (make-instance 'option
+ :label (getf option :label)
+ :value (getf option :value)))
+ (getf field :options))
+ :onclick (getf field :onclick)
+ :onchange (getf field :onchange)))
+ fields)))
diff --git a/service/home-service.lisp b/service/home-service.lisp
new file mode 100644
index 0000000..fd96b36
--- /dev/null
+++ b/service/home-service.lisp
@@ -0,0 +1,18 @@
+;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+(declaim (optimize (speed 0) (safety 3) (debug 3)))
+
+(in-package #:ldapadmin)
+
+(defclass home-service (rest-service)
+ ((content :initarg :content
+ :initform nil
+ :accessor content))
+ (:documentation ""))
+
+(defmethod initialize-instance :after ((home-service home-service) &key)
+ (setf (content home-service) (format nil "Welcome to the ~a website" (title *webapp*))))
+
+(defun home-json (&optional message errormsg)
+ (objects-to-json `(,(make-instance 'home-service
+ :message message
+ :errormsg errormsg))))
diff --git a/service/home.lisp b/service/home.lisp
deleted file mode 100644
index 488b86f..0000000
--- a/service/home.lisp
+++ /dev/null
@@ -1,18 +0,0 @@
-;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
-(declaim (optimize (speed 0) (safety 3) (debug 3)))
-
-(in-package #:ldapadmin)
-
-;; ========================================================================== ;;
-
-(defclass home (rest-service)
- ((content :initarg :content
- :initform nil
- :accessor content))
- (:documentation ""))
-
-(defmethod initialize-instance :after ((home home) &key)
- (setf (content home) (concatenate 'string "Welcome to the " (title *webapp*))))
-
-(defun home-json ()
- (objects-to-json `(,(make-instance 'home))))
diff --git a/service/inetorg-add-service.lisp b/service/inetorg-add-service.lisp
new file mode 100644
index 0000000..9647060
--- /dev/null
+++ b/service/inetorg-add-service.lisp
@@ -0,0 +1,57 @@
+;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+(declaim (optimize (speed 0) (safety 3) (debug 3)))
+
+(in-package #:ldapadmin)
+
+(defclass inetorg-add-service (auth-service)
+ ((form :initarg :form
+ :initform nil
+ :accessor form)
+ (title :initarg :title
+ :initform nil
+ :accessor title))
+ (:documentation ""))
+
+(defmethod initialize-instance :after ((inetorg-add-service inetorg-add-service) &key)
+ (setf (title inetorg-add-service) "Add InetOrg Entry")
+ (setf (form inetorg-add-service) (make-form "inetorg-add-form"
+ nil
+ t
+ '((:name "add-givenname" :label "givenName" :field-type "text" :required "required")
+ (:name "add-sn" :label "sn" :field-type "text" :required "required")
+ (:name "add-mail" :label "mail" :field-type "text")
+ (:name "add-postaladdress" :label "postalAddress" :field-type "text")
+ (:name "add-postalcode" :label "postalCode" :field-type "text")
+ (:name "add-st" :label "st" :field-type "text")
+ (:name "add-l" :label "l" :field-type "text")
+ (:name "add-telephonenumber" :label "telephoneNumber" :field-type "text")
+ (:name "add-mobile" :label "mobile" :field-type "text")
+ (:name "add-businesscategory" :label "businessCategory" :field-type "text")
+ (:label "Create InetOrg Entry" :field-type "button" :onclick "on_inetorg_add_submit_clicked()")))))
+
+(defun inetorg-add-json ()
+ (with-auth (instance inetorg-add-service)
+ t))
+
+(defclass inetorg-add-submit-service (auth-service)
+ ((location-p :initarg :location-p
+ :initform nil
+ :accessor location-p))
+ (:documentation ""))
+
+(defun inetorg-add-submit-json (givenname sn mail postaladdress postalcode st l telephonenumber mobile businesscategory)
+ (with-auth (instance inetorg-add-submit-service)
+ (with-ldap (ldap)
+ (let ((ldap-user (make-instance 'ldap-user
+ :givenname givenname
+ :sn sn
+ :mail mail
+ :postaladdress postaladdress
+ :postalcode postalcode
+ :st st
+ :l l
+ :telephonenumber telephonenumber
+ :mobile mobile
+ :businesscategory businesscategory)))
+ (add-ldap-user ldap-user ldap)
+ (setf (message instance) "InetOrg entry created successfully.")))))
diff --git a/service/inetorg-add.lisp b/service/inetorg-add.lisp
deleted file mode 100644
index c094375..0000000
--- a/service/inetorg-add.lisp
+++ /dev/null
@@ -1,56 +0,0 @@
-;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
-(declaim (optimize (speed 0) (safety 3) (debug 3)))
-
-(in-package #:ldapadmin)
-
-;; ========================================================================== ;;
-;; inetorg-add
-
-(defclass inetorg-add (auth-service generic-form)
- ((instructions :initarg :instructions
- :initform nil
- :accessor instructions))
- (:documentation ""))
-
-(define-generic-form-constructor (inetorg-add "inetorg-add-form" "/inetorg/add/submit")
- '((:name "add-givenname" :label "givenName" :field-type "text")
- (:name "add-sn" :label "sn" :field-type "text")
- (:name "add-mail" :label "mail" :field-type "text")
- (:name "add-postaladdress" :label "postalAddress" :field-type "text")
- (:name "add-postalcode" :label "postalCode" :field-type "text")
- (:name "add-st" :label "st" :field-type "text")
- (:name "add-l" :label "l" :field-type "text")
- (:name "add-telephonenumber" :label "telephoneNumber" :field-type "text")
- (:name "add-mobile" :label "mobile" :field-type "text")
- (:name "add-businesscategory" :label "businessCategory" :field-type "text")
- (:name "add-submit" :label "Create InetOrg Entry" :field-type "button")))
-
-(defun inetorg-add-json ()
- (with-auth (instance inetorg-add)
- (setf (instructions instance) "Use the form to add a new InetOrg entry.")))
-
-;; ========================================================================== ;;
-;; inetorg-add-submit
-
-(defclass inetorg-add-submit (auth-service)
- ((location-p :initarg :location-p
- :initform nil
- :accessor location-p))
- (:documentation ""))
-
-(defun inetorg-add-submit-json (givenname sn mail postaladdress postalcode st l telephonenumber mobile businesscategory)
- (with-auth (instance inetorg-add-submit)
- (with-ldap (ldap)
- (let ((ldap-user (make-instance 'ldap-user
- :givenname givenname
- :sn sn
- :mail mail
- :postaladdress postaladdress
- :postalcode postalcode
- :st st
- :l l
- :telephonenumber telephonenumber
- :mobile mobile
- :businesscategory businesscategory)))
- (add-ldap-user ldap-user ldap)
- (setf (message instance) "InetOrg entry created successfully.")))))
diff --git a/service/inetorg-delete.lisp b/service/inetorg-delete-service.lisp
index d01db5d..1bcac65 100644
--- a/service/inetorg-delete.lisp
+++ b/service/inetorg-delete-service.lisp
@@ -3,9 +3,6 @@
(in-package #:ldapadmin)
-;; ========================================================================== ;;
-;; inetorg-delete
-
(defclass inetorg-delete (auth-service)
((cn :initarg :cn
:initform nil
@@ -19,9 +16,6 @@
(with-auth (instance inetorg-delete)
(setf (cn instance) cn)))
-;; ========================================================================== ;;
-;; inetorg-delete-submit
-
(defclass inetorg-delete-submit (auth-service)
()
(:documentation ""))
diff --git a/service/inetorg-modify-service.lisp b/service/inetorg-modify-service.lisp
new file mode 100644
index 0000000..293c43b
--- /dev/null
+++ b/service/inetorg-modify-service.lisp
@@ -0,0 +1,60 @@
+;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+(declaim (optimize (speed 0) (safety 3) (debug 3)))
+
+(in-package #:ldapadmin)
+
+(defclass inetorg-modify-service (auth-service)
+ ((form :initarg :form
+ :initform nil
+ :accessor form)
+ (title :initarg :title
+ :initform nil
+ :accessor title)
+ (location-p :initarg :location-p
+ :initform nil
+ :accessor location-p))
+ (:documentation ""))
+
+(defmethod initialize-instance :after ((inetorg-modify-service inetorg-modify-service) &key)
+ (setf (form inetorg-modify-service) (make-form "inetorg-modify-form"
+ nil
+ t
+ '((:name "modify-givenname" :label "givenName" :field-type "text" :value )
+ (:name "modify-sn" :label "sn" :field-type "text")
+ (:name "modify-mail" :label "mail" :field-type "text")
+ (:name "modify-postaladdress" :label "postalAddress" :field-type "text")
+ (:name "modify-postalcode" :label "postalCode" :field-type "text")
+ (:name "modify-st" :label "st" :field-type "text")
+ (:name "modify-l" :label "l" :field-type "text")
+ (: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")))
+
+(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)
+ ((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-ldap (ldap)
+ (let ((ldap-user (make-instance 'ldap-user
+ :givenname givenname
+ :sn sn
+ :mail mail
+ :postaladdress postaladdress
+ :postalcode postalcode
+ :st st
+ :l l
+ :telephonenumber telephonenumber
+ :mobile mobile
+ :businesscategory businesscategory)))
+ (modify-ldap-user ldap-user ldap)
+ (setf (message instance) "InetOrg entry saved successfully.")))))
diff --git a/service/inetorg-modify.lisp b/service/inetorg-modify.lisp
deleted file mode 100644
index a8b5b21..0000000
--- a/service/inetorg-modify.lisp
+++ /dev/null
@@ -1,60 +0,0 @@
-;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
-(declaim (optimize (speed 0) (safety 3) (debug 3)))
-
-(in-package #:ldapadmin)
-
-;; ========================================================================== ;;
-;; inetorg-modify
-
-(defclass inetorg-modify (auth-service generic-form)
- ((ldap-user-values :initarg :ldap-user-values
- :initform nil
- :accessor ldap-user-values)
- (location-p :initarg :location-p
- :initform nil
- :accessor location-p))
- (:documentation ""))
-
-(define-generic-form-constructor (inetorg-modify "inetorg-modify-form" "/inetorg/modify/submit")
- '((: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")
- (:name "modify-postalcode" :label "postalCode" :field-type "text")
- (:name "modify-st" :label "st" :field-type "text")
- (:name "modify-l" :label "l" :field-type "text")
- (:name "modify-telephonenumber" :label "telephoneNumber" :field-type "text")
- (:name "modify-mobile" :label "mobile" :field-type "text")
- (:name "modify-businesscategory" :label "businessCategory" :field-type "text")
- (:name "modify-submit" :label "Modify InetOrg Entry" :field-type "button")))
-
-(defun inetorg-modify-json (cn)
- (with-auth (instance inetorg-modify)
- (with-ldap (ldap)
- (setf (ldap-user-values instance) (get-ldap-user ldap cn)))))
-
-;; ========================================================================== ;;
-;; inetorg-modify-submit
-
-(defclass inetorg-modify-submit (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-ldap (ldap)
- (let ((ldap-user (make-instance 'ldap-user
- :givenname givenname
- :sn sn
- :mail mail
- :postaladdress postaladdress
- :postalcode postalcode
- :st st
- :l l
- :telephonenumber telephonenumber
- :mobile mobile
- :businesscategory businesscategory)))
- (modify-ldap-user ldap-user ldap)
- (setf (message instance) "InetOrg entry saved successfully.")))))
diff --git a/service/inetorg-view-service.lisp b/service/inetorg-view-service.lisp
new file mode 100644
index 0000000..5cbd0c6
--- /dev/null
+++ b/service/inetorg-view-service.lisp
@@ -0,0 +1,72 @@
+;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+(declaim (optimize (speed 0) (safety 3) (debug 3)))
+
+(in-package #:ldapadmin)
+
+(defclass inetorg-view (auth-service)
+ ((title :initarg :title
+ :initform nil
+ :accessor title))
+ (:documentation ""))
+
+(defun inetorg-view-json ()
+ (with-auth (instance inetorg-view)
+ (setf (title instance) "Use the form to filter the InetOrg results.")))
+
+(defclass inetorg-view-search-service (auth-service)
+ ((form :initarg :form
+ :initform nil
+ :accessor form)
+ (title :initarg :title
+ :initform nil
+ :accessor title)
+ (location-p :initarg :location-p
+ :initform nil
+ :accessor location-p))
+ (:documentation ""))
+
+(defmethod initialize-instance :after ((inetorg-view-search-service inetorg-view-search-service) &key)
+ (setf (form inetorg-view-search-service) (make-form "inetorg-view-search-form"
+ nil
+ t
+ '((:name "view-givenname" :label "givenName" :field-type "text")
+ (:name "view-sn" :label "sn" :field-type "text")
+ (:name "view-mail" :label "mail" :field-type "text")
+ (:name "view-postaladdress" :label "postalAddress" :field-type "text")
+ (:name "view-postalcode" :label "postalCode" :field-type "text")
+ (:name "view-st" :label "st" :field-type "text")
+ (:name "view-l" :label "l" :field-type "text")
+ (:name "view-telephonenumber" :label "telephoneNumber" :field-type "text")
+ (:name "view-mobile" :label "mobile" :field-type "text")
+ (:name "view-businesscategory" :label "businessCategory" :field-type "text")
+ (:label "Search InetOrg Entries" :field-type "button" :onclick "on_inetorg_view_search_clicked()")))))
+
+(defun inetorg-view-search-json ()
+ (with-auth (instance inetorg-view-search-service)
+ nil))
+
+(defclass inetorg-view-results (auth-service)
+ ((results :initarg :results
+ :initform nil
+ :accessor results)
+ (location-p :initarg :location-p
+ :initform nil
+ :accessor location-p))
+ (:documentation ""))
+
+(defun inetorg-view-results-json (givenname sn mail postaladdress postalcode st l telephonenumber mobile businesscategory)
+ (with-auth (instance inetorg-view-results-service)
+ (with-ldap (ldap)
+ (setf (results instance)
+ (sort (search-ldap-users ldap
+ `((:givenname ,givenname)
+ (:sn ,sn)
+ (:mail ,mail)
+ (:postaladdress ,postaladdress)
+ (:postalcode ,postalcode)
+ (:st ,st)
+ (:l ,l)
+ (:telephonenumber ,telephonenumber)
+ (:mobile ,mobile)
+ (:businesscategory ,businesscategory)))
+ (lambda (x y) (string< (get-cn x) (get-cn y))))))))
diff --git a/service/inetorg-view.lisp b/service/inetorg-view.lisp
deleted file mode 100644
index f5bf2f2..0000000
--- a/service/inetorg-view.lisp
+++ /dev/null
@@ -1,72 +0,0 @@
-;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
-(declaim (optimize (speed 0) (safety 3) (debug 3)))
-
-(in-package #:ldapadmin)
-
-;; ========================================================================== ;;
-;; inetorg-view
-
-(defclass inetorg-view (auth-service)
- ((instructions :initarg :instructions
- :initform nil
- :accessor instructions))
- (:documentation ""))
-
-(defun inetorg-view-json ()
- (with-auth (instance inetorg-view)
- (setf (instructions instance) "Use the form to filter the InetOrg results.")))
-
-;; ========================================================================== ;;
-;; inetorg-view-search
-
-(defclass inetorg-view-search (auth-service generic-form)
- ((location-p :initarg :location-p
- :initform nil
- :accessor location-p))
- (:documentation ""))
-
-(define-generic-form-constructor (inetorg-view-search "inetorg-view-search-form" "/inetorg/view/results")
- '((:name "view-givenname" :label "givenName" :field-type "text")
- (:name "view-sn" :label "sn" :field-type "text")
- (:name "view-mail" :label "mail" :field-type "text")
- (:name "view-postaladdress" :label "postalAddress" :field-type "text")
- (:name "view-postalcode" :label "postalCode" :field-type "text")
- (:name "view-st" :label "st" :field-type "text")
- (:name "view-l" :label "l" :field-type "text")
- (:name "view-telephonenumber" :label "telephoneNumber" :field-type "text")
- (:name "view-mobile" :label "mobile" :field-type "text")
- (:name "view-businesscategory" :label "businessCategory" :field-type "text")
- (:name "view-submit" :label "Search InetOrg Entries" :field-type "button")))
-
-(defun inetorg-view-search-json ()
- (with-auth (instance inetorg-view-search)
- nil))
-
-;; ========================================================================== ;;
-;; inetorg-view-results
-
-(defclass inetorg-view-results (auth-service)
- ((results :initarg :results
- :initform nil
- :accessor results)
- (location-p :initarg :location-p
- :initform nil
- :accessor location-p))
- (:documentation ""))
-
-(defun inetorg-view-results-json (givenname sn mail postaladdress postalcode st l telephonenumber mobile businesscategory)
- (with-auth (instance inetorg-view-results)
- (with-ldap (ldap)
- (setf (results instance)
- (sort (search-ldap-users ldap
- `((:givenname ,givenname)
- (:sn ,sn)
- (:mail ,mail)
- (:postaladdress ,postaladdress)
- (:postalcode ,postalcode)
- (:st ,st)
- (:l ,l)
- (:telephonenumber ,telephonenumber)
- (:mobile ,mobile)
- (:businesscategory ,businesscategory)))
- (lambda (x y) (string< (get-cn x) (get-cn y))))))))
diff --git a/service/login-authenticate.lisp b/service/login-authenticate.lisp
deleted file mode 100644
index 5b657a0..0000000
--- a/service/login-authenticate.lisp
+++ /dev/null
@@ -1,24 +0,0 @@
-;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
-(declaim (optimize (speed 0) (safety 3) (debug 3)))
-
-(in-package #:ldapadmin)
-
-;; ========================================================================== ;;
-
-(defclass login-authenticate (rest-service)
- ((location-p :initarg :location-p
- :initform nil
- :accessor location-p))
- (:documentation ""))
-
-(defmethod initialize-instance :after ((login-authenticate login-authenticate) &key auth-result)
- (if auth-result
- (setf (message login-authenticate) "Successfully logged in.")
- (setf (errormsg login-authenticate) "Login failed.")))
-
-(defun login-authenticate-json (dn password)
- (let ((auth-result nil))
- (when (check-ldap-password (ldap *webapp*) dn password)
- (setf (session-value :permissions) "admin")
- (setf auth-result t))
- (objects-to-json `(,(make-instance 'login-authenticate :auth-result auth-result)))))
diff --git a/service/login-service.lisp b/service/login-service.lisp
new file mode 100644
index 0000000..8de0ec5
--- /dev/null
+++ b/service/login-service.lisp
@@ -0,0 +1,43 @@
+;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+(declaim (optimize (speed 0) (safety 3) (debug 3)))
+
+(in-package #:ldapadmin)
+
+(defclass login-service (rest-service)
+ ((form :initarg :form
+ :initform nil
+ :accessor form)
+ (title :initarg :title
+ :initform nil
+ :accessor title))
+ (:documentation ""))
+
+(defmethod initialize-instance :after ((login-service login-service) &key)
+ (setf (title login-service) "Login")
+ (setf (form login-service) (make-form "login-form"
+ nil
+ t
+ '((:name "dn" :label "DN" :field-type "text" :required "required")
+ (:name "password" :label "Password" :field-type "password" :required "required")
+ (:label "Login" :field-type "button" :onclick "on_login_submit_clicked()")))))
+
+(defun login-json ()
+ (objects-to-json `(,(make-instance 'login-service))))
+
+(defclass login-authenticate-service (rest-service)
+ ((location-p :initarg :location-p
+ :initform nil
+ :accessor location-p))
+ (:documentation ""))
+
+(defmethod initialize-instance :after ((login-authenticate-service login-authenticate-service) &key auth-result)
+ (if auth-result
+ (setf (message login-authenticate-service) "Successfully logged in.")
+ (setf (errormsg login-authenticate-service) "Login failed.")))
+
+(defun login-authenticate-json (username pwd)
+ (let ((auth-result nil))
+ (when (check-ldap-password (ldap *webapp*) dn password)
+ (setf (session-value :permissions) "admin")
+ (setf auth-result t))
+ (objects-to-json `(,(make-instance 'login-authenticate-service :auth-result auth-result)))))
diff --git a/service/login.lisp b/service/login.lisp
deleted file mode 100644
index 6d005d7..0000000
--- a/service/login.lisp
+++ /dev/null
@@ -1,18 +0,0 @@
-;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
-(declaim (optimize (speed 0) (safety 3) (debug 3)))
-
-(in-package #:ldapadmin)
-
-;; ========================================================================== ;;
-
-(defclass login (generic-form)
- ()
- (:documentation ""))
-
-(define-generic-form-constructor (login "login-form" "/login/authenticate")
- '((:name "dn" :label "DN" :field-type "text")
- (:name "password" :label "Password" :field-type "password")
- (:name "submit" :label "Login" :field-type "button")))
-
-(defun login-json ()
- (objects-to-json `(,(make-instance 'login))))
diff --git a/service/logout-service.lisp b/service/logout-service.lisp
new file mode 100644
index 0000000..d6aef8f
--- /dev/null
+++ b/service/logout-service.lisp
@@ -0,0 +1,17 @@
+;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+(declaim (optimize (speed 0) (safety 3) (debug 3)))
+
+(in-package #:ldapadmin)
+
+(defclass logout-service (rest-service)
+ ((location-p :initarg :location-p
+ :initform nil
+ :accessor location-p))
+ (:documentation ""))
+
+(defmethod initialize-instance :after ((logout-service logout-service) &key)
+ (setf (message logout-service) "You are now logged out."))
+
+(defun logout-json ()
+ (set-user (make-default-user))
+ (objects-to-json `(,(make-instance 'logout-service))))
diff --git a/service/logout.lisp b/service/logout.lisp
deleted file mode 100644
index 219e7e2..0000000
--- a/service/logout.lisp
+++ /dev/null
@@ -1,19 +0,0 @@
-;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
-(declaim (optimize (speed 0) (safety 3) (debug 3)))
-
-(in-package #:ldapadmin)
-
-;; ========================================================================== ;;
-
-(defclass logout (rest-service)
- ((location-p :initarg :location-p
- :initform nil
- :accessor location-p))
- (:documentation ""))
-
-(defmethod initialize-instance :after ((logout logout) &key)
- (setf (message logout) "You are now logged out."))
-
-(defun logout-json ()
- (setf (session-value :permissions) "anonymous")
- (objects-to-json `(,(make-instance 'logout))))
diff --git a/service/menu.lisp b/service/menu-service.lisp
index 069cb11..25cad07 100644
--- a/service/menu.lisp
+++ b/service/menu-service.lisp
@@ -3,8 +3,6 @@
(in-package #:ldapadmin)
-;; ========================================================================== ;;
-
(defparameter *menu-config* '((:id "a_menu_home" :label "Home" :url "/home" :handler "/home" :permission "t")
(:id "a_menu_login" :label "Login" :url "/login" :handler "/login" :permission "anonymous")
(:id "a_menu_logout" :label "Logout" :url "/logout" :handler "/logout" :permission "admin")
diff --git a/service/rest-service.lisp b/service/rest-service.lisp
index 693463f..b34817f 100644
--- a/service/rest-service.lisp
+++ b/service/rest-service.lisp
@@ -3,8 +3,6 @@
(in-package #:ldapadmin)
-;; ========================================================================== ;;
-
(defclass rest-service (base-service)
((location :initarg :location
:initform nil