|
|
@@ -135,15 +135,15 @@
|
|
|
(otherwise +404+)))))
|
|
|
|
|
|
(defmacro with-user ((info) &body body)
|
|
|
- (with-gensyms (auth bearer)
|
|
|
- `(let* ((,auth (ignore-errors (gethash "authorization" (getf myway:*env* :headers))))
|
|
|
+ (with-gensyms (auth bearer headers)
|
|
|
+ `(let* ((,headers (getf myway:*env* :headers)
|
|
|
+ (,auth (ignore-errors (gethash "authorization" ,headers)))
|
|
|
(,bearer (when (and ,auth
|
|
|
(> (length (the string ,auth)) 7)
|
|
|
(equal "Bearer " (subseq (the string ,auth) 0 7)))
|
|
|
(subseq (the string ,auth) 7)))
|
|
|
(,info (when ,bearer (gethash ,bearer (server-token-user *server*)))))
|
|
|
- (when (and (null ,info)
|
|
|
- (equal (getf myway:*env* :remote-addr) "127.0.0.1"))
|
|
|
+ (when (and (null ,info) (null (gethash "x-real-ip" ,headers)))
|
|
|
(setf ,info `(:|username| "admin" :|id| 0 :|first_name| "cli" :|last_name| "admin")))
|
|
|
(if ,info (handler-case (progn ,@body) (error (e) (log:error e) (print e)))
|
|
|
+401+))))
|