nullify this duplicate code prior to deletion.

This commit is contained in:
Brian O'Reilly 2025-10-03 13:14:04 -04:00
parent dee883e76e
commit ce39a0ca1a
1 changed files with 18 additions and 18 deletions

View File

@ -21,25 +21,25 @@
(defparameter *supported-formats* '("mp3" "flac" "ogg" "wav")) (defparameter *supported-formats* '("mp3" "flac" "ogg" "wav"))
;; Authentication functions ;; ;; Authentication functions
(defun require-authentication () ;; (defun require-authentication ()
"Require user to be authenticated" ;; "Require user to be authenticated"
(handler-case ;; (handler-case
(unless (session:field "user-id") ;; (unless (session:field "user-id")
(radiance:redirect "/asteroid/login")) ;; (radiance:redirect "/asteroid/login"))
(error (e) ;; (error (e)
(format t "Authentication error: ~a~%" e) ;; (format t "Authentication error: ~a~%" e)
(radiance:redirect "/asteroid/login")))) ;; (radiance:redirect "/asteroid/login"))))
(defun require-role (role) ;; (defun require-role (role)
"Require user to have a specific role" ;; "Require user to have a specific role"
(handler-case ;; (handler-case
(let ((current-user (get-current-user))) ;; (let ((current-user (get-current-user)))
(unless (and current-user (user-has-role-p current-user role)) ;; (unless (and current-user (user-has-role-p current-user role))
(radiance:redirect "/asteroid/login"))) ;; (radiance:redirect "/asteroid/login")))
(error (e) ;; (error (e)
(format t "Role check error: ~a~%" e) ;; (format t "Role check error: ~a~%" e)
(radiance:redirect "/asteroid/login")))) ;; (radiance:redirect "/asteroid/login"))))
;; API Routes ;; API Routes
(define-page admin-scan-library #@"/admin/scan-library" () (define-page admin-scan-library #@"/admin/scan-library" ()