]> www.vanbest.org Git - motioneye-debian/commitdiff
http 403 is used now for unauthorized requests
authorCalin Crisan <ccrisan@gmail.com>
Fri, 10 Jun 2016 11:12:53 +0000 (14:12 +0300)
committerCalin Crisan <ccrisan@gmail.com>
Fri, 10 Jun 2016 11:12:53 +0000 (14:12 +0300)
motioneye/config.py
motioneye/handlers.py
motioneye/static/js/main.js

index ad290f7f36613a595c7eebb3e89ac34940e74c5f..92b8b209d082f235775559da206c89eaf5627b9d 100644 (file)
@@ -1499,6 +1499,18 @@ def motion_rtsp_support():
         return []
 
 
+def motion_mmal_support():
+    import motionctl
+
+    try:
+        binary, version = motionctl.find_motion()  # @UnusedVariable
+        
+        return version == 'mmaltest'
+
+    except:
+        return False
+
+
 def invalidate():
     global _main_config_cache
     global _camera_config_cache
index 7a3ea78698fdac7620eb4c2b01399026382c527f..63159a8528923d7c5675d6261d9c487a19361339 100644 (file)
@@ -158,6 +158,7 @@ class BaseHandler(RequestHandler):
                 user = self.current_user
                 if (user is None) or (user != 'admin' and (admin or _admin)):
                     self.set_header('Content-Type', 'application/json')
+                    self.set_status(403)
 
                     return self.finish_json({'error': 'unauthorized', 'prompt': prompt})
 
index f1fc9f058472c719b93fb55aae7f4d2efce32986..0a92b009642eb2ceaee08d7334cc6691fefb1f06 100644 (file)
@@ -419,32 +419,38 @@ function ajax(method, url, data, callback, error, timeout) {
     
     url = addAuthParams(method, url, processData ? data : null);
     
+    function onResponse(data) {
+        if (data && data.error == 'unauthorized') {
+            if (data.prompt) {
+                runLoginDialog(function () {
+                    ajax(method, origUrl, origData, callback, error);
+                });
+            }
+            
+            window._loginRetry = true;
+        }
+        else {
+            delete window._loginRetry;
+            if (callback) {
+                $('body').toggleClass('admin', isAdmin());
+                callback(data);
+            }
+        }
+    }
+
     var options = {
         type: method,
         url: url,
         data: data,
         timeout: timeout || 300 * 1000,
-        success: function (data) {
-            if (data && data.error == 'unauthorized') {
-                if (data.prompt) {
-                    runLoginDialog(function () {
-                        ajax(method, origUrl, origData, callback, error);
-                    });
-                }
-                
-                window._loginRetry = true;
-            }
-            else {
-                delete window._loginRetry;
-                if (callback) {
-                    $('body').toggleClass('admin', isAdmin());
-                    callback(data);
-                }
-            }
-        },
+        success: onResponse,
         contentType: json ? 'application/json' : false,
         processData: processData,
         error: error || function (request, options, error) {
+            if (request.status == 403) {
+                return onResponse(request.responseJSON);
+            }
+            
             showErrorMessage();
             if (callback) {
                 callback();