summaryrefslogtreecommitdiff
path: root/service/login-authenticate.lisp
blob: 7ef038f3ab52c8d25451ef52b1d26b192c47d965 (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
;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
(declaim (optimize (speed 0) (safety 3) (debug 3)))

(in-package #:music-dispensary)

;; ========================================================================== ;;

(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)))))