##// END OF EJS Templates
auth: XHRRequired decorator is no longer required....
marcink -
r1999:6219530b default
parent child Browse files
Show More
@@ -43,7 +43,7 b' from rhodecode.lib.utils import jsonify'
43 from rhodecode.lib.utils2 import safe_unicode, str2bool, safe_int
43 from rhodecode.lib.utils2 import safe_unicode, str2bool, safe_int
44 from rhodecode.lib.auth import (
44 from rhodecode.lib.auth import (
45 LoginRequired, NotAnonymous, HasUserGroupPermissionAnyDecorator,
45 LoginRequired, NotAnonymous, HasUserGroupPermissionAnyDecorator,
46 HasPermissionAnyDecorator, XHRRequired)
46 HasPermissionAnyDecorator)
47 from rhodecode.lib.base import BaseController, render
47 from rhodecode.lib.base import BaseController, render
48 from rhodecode.model.permission import PermissionModel
48 from rhodecode.model.permission import PermissionModel
49 from rhodecode.model.scm import UserGroupList
49 from rhodecode.model.scm import UserGroupList
@@ -1339,28 +1339,6 b' class NotAnonymous(object):'
1339 return func(*fargs, **fkwargs)
1339 return func(*fargs, **fkwargs)
1340
1340
1341
1341
1342 class XHRRequired(object):
1343 # TODO(marcink): remove this in favor of the predicates in pyramid routes
1344
1345 def __call__(self, func):
1346 return get_cython_compat_decorator(self.__wrapper, func)
1347
1348 def _get_request(self):
1349 return get_request(self)
1350
1351 def __wrapper(self, func, *fargs, **fkwargs):
1352 from pylons.controllers.util import abort
1353 request = self._get_request()
1354
1355 log.debug('Checking if request is XMLHttpRequest (XHR)')
1356 xhr_message = 'This is not a valid XMLHttpRequest (XHR) request'
1357
1358 if not request.is_xhr:
1359 abort(400, detail=xhr_message)
1360
1361 return func(*fargs, **fkwargs)
1362
1363
1364 class PermsDecorator(object):
1342 class PermsDecorator(object):
1365 """
1343 """
1366 Base class for controller decorators, we extract the current user from
1344 Base class for controller decorators, we extract the current user from
General Comments 0
You need to be logged in to leave comments. Login now