Permalink
Browse files

feature(ajax): elgg_ajax_gatekeeper for asserting resources as Ajax-only

  • Loading branch information...
mrclay committed Jun 1, 2015
1 parent 706f6c1 commit 4e0e1a5b9aa277d9fe14f484122cd2c89ba99fa4
Showing with 15 additions and 5 deletions.
  1. +1 −5 engine/lib/elgglib.php
  2. +14 −0 engine/lib/pagehandler.php
View
@@ -1462,11 +1462,7 @@ function _elgg_js_page_handler($page) {
* @access private
*/
function _elgg_ajax_page_handler($segments) {
// the ajax page handler should only be called from an xhr
if (!elgg_is_xhr()) {
register_error(_elgg_services()->translator->translate('ajax:not_is_xhr'));
forward(null, '400');
}
elgg_ajax_gatekeeper();
if (count($segments) < 2) {
return false;
View
@@ -206,6 +206,20 @@ function elgg_entity_gatekeeper($guid, $type = null, $subtype = null) {
}
}
/**
* Require that the current request be an XHR. If not, execution of the current function
* will end and a 400 response page will be sent.
*
* @return void
* @since 1.12.0
*/
function elgg_ajax_gatekeeper() {
if (!elgg_is_xhr()) {
register_error(_elgg_services()->translator->translate('ajax:not_is_xhr'));
forward(null, '400');
}
}
/**
* Front page handler
*

0 comments on commit 4e0e1a5

Please sign in to comment.