set correct content type for JSON requests

This commit is contained in:
Roland Gruber 2016-01-16 19:17:19 +00:00
parent edef026b24
commit f2168738bd
3 changed files with 24 additions and 9 deletions

View File

@ -5,7 +5,8 @@ March 2016 5.3
- Personal/Unix: support K5KEY hash type for smbk5pwd - Personal/Unix: support K5KEY hash type for smbk5pwd
- New NIS netgroup module for hosts - New NIS netgroup module for hosts
- fixed bugs: - fixed bugs:
-> autoload errors in tree view -> Autoload errors in tree view
-> Set correct content type on JSON requests (174)
- LAM Pro: - LAM Pro:
-> Support for LDAP views based on nsview object class -> Support for LDAP views based on nsview object class
-> Password notification jobs support to print expiration date in email -> Password notification jobs support to print expiration date in email

View File

@ -4,7 +4,7 @@ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2010 Cedric Dugas and Olivier Refalo Copyright (C) 2010 Cedric Dugas and Olivier Refalo
2011 - 2015 Roland Gruber 2011 - 2016 Roland Gruber
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -30,6 +30,10 @@ if (strtolower(session_module_name()) == 'files') {
session_save_path(dirname(__FILE__) . '/../../sess'); session_save_path(dirname(__FILE__) . '/../../sess');
} }
if (!headers_sent()) {
header('Content-Type: application/json; charset=utf-8');
}
@session_start(); @session_start();
setlanguage(); setlanguage();

View File

@ -3,18 +3,18 @@
$Id$ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2011 - 2015 Roland Gruber Copyright (C) 2011 - 2016 Roland Gruber
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@ -53,14 +53,15 @@ lamAjax::handleRequest();
* Manages all AJAX requests. * Manages all AJAX requests.
*/ */
class lamAjax { class lamAjax {
/** /**
* Manages an AJAX request. * Manages an AJAX request.
*/ */
public static function handleRequest() { public static function handleRequest() {
lamAjax::setHeader();
// check token // check token
validateSecurityToken(false); validateSecurityToken(false);
if (isset($_GET['module']) && isset($_GET['scope']) && in_array($_GET['module'], getAvailableModules($_GET['scope']))) { if (isset($_GET['module']) && isset($_GET['scope']) && in_array($_GET['module'], getAvailableModules($_GET['scope']))) {
if (isset($_GET['useContainer']) && ($_GET['useContainer'] == '1')) { if (isset($_GET['useContainer']) && ($_GET['useContainer'] == '1')) {
if (!isset($_SESSION['account'])) die(); if (!isset($_SESSION['account'])) die();
@ -89,6 +90,15 @@ class lamAjax {
} }
} }
/**
* Sets JSON HTTP header.
*/
private function setHeader() {
if (!headers_sent()) {
header('Content-Type: application/json; charset=utf-8');
}
}
/** /**
* Manages a password change request on the edit account page. * Manages a password change request on the edit account page.
* *
@ -98,7 +108,7 @@ class lamAjax {
$return = $_SESSION['account']->setNewPassword($input); $return = $_SESSION['account']->setNewPassword($input);
echo json_encode($return); echo json_encode($return);
} }
/** /**
* Checks if a password is accepted by LAM's password policy. * Checks if a password is accepted by LAM's password policy.
* *
@ -109,7 +119,7 @@ class lamAjax {
$result = checkPasswordStrength($password, null, null); $result = checkPasswordStrength($password, null, null);
echo json_encode(array("result" => $result)); echo json_encode(array("result" => $result));
} }
} }