thirdparty/google_appengine/google/appengine/ext/admin/templates/js/webhook.js
changeset 2864 2e0b0af889be
parent 2413 d0b7dac5325c
equal deleted inserted replaced
2862:27971a13089f 2864:2e0b0af889be
    31       this.headers[header] = value;
    31       this.headers[header] = value;
    32     } else if (key == 'payload') {
    32     } else if (key == 'payload') {
    33       this.payload = value;
    33       this.payload = value;
    34     }
    34     }
    35   }
    35   }
    36   
    36 
    37   if (this.action == '') {
    37   if (this.action == '') {
    38     return 'action not found';
    38     return 'action not found';
    39   }
    39   }
    40   if (this.method == '') {
    40   if (this.method == '') {
    41     return 'method not found';
    41     return 'method not found';
    59     req.send(this.payload);
    59     req.send(this.payload);
    60   } catch (e) {
    60   } catch (e) {
    61     callback(this, req, e);
    61     callback(this, req, e);
    62     return;
    62     return;
    63   }
    63   }
    64   callback(this, req, null);
    64 
       
    65   // If the responseText matches our <form action="/_ah/login then the
       
    66   // user is not logged in as an Administrator so we'll fake the request.
       
    67   if (req.responseText.match(/<form[^>]+_ah\/login/)) {
       
    68     var fakeReq = {
       
    69       'status': 403,
       
    70       'responseText': 'Current logged in user is not authorized ' +
       
    71                       'to view this page'
       
    72     }
       
    73     fakeReq.getAllResponseHeaders = function(){};
       
    74     callback(this, fakeReq, null);
       
    75   } else {
       
    76     callback(this, req, null);
       
    77   }
    65 };
    78 };
    66 
    79 
    67 Webhook.prototype.run = function(callback) {
    80 Webhook.prototype.run = function(callback) {
    68   var error = this.parse();
    81   var error = this.parse();
    69   if (error != '') {
    82   if (error != '') {