Skip to content

Commit

Permalink
FIX A non admin user should not be able to set/unset a user as admin
Browse files Browse the repository at this point in the history
even if he has right to manage permission
  • Loading branch information
eldy committed Jun 4, 2016
1 parent c59c86e commit c2e853d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion htdocs/user/card.php
Expand Up @@ -333,7 +333,7 @@
$object->gender = GETPOST("gender", 'alpha');
$object->pass = GETPOST("password");
$object->api_key = (GETPOST("api_key", 'alpha')) ? GETPOST("api_key", 'alpha') : $object->api_key;
$object->admin = empty($user->admin) ? 0 : GETPOST("admin"); // A user can only be set admin by an admin
if (! empty($user->admin)) $object->admin = GETPOST("admin"); // admin flag can only be set/unset by an admin user. A test is also done later when forging sql request
$object->address = GETPOST('address', 'alpha');
$object->zip = GETPOST('zipcode', 'alpha');
$object->town = GETPOST('town', 'alpha');
Expand Down
2 changes: 1 addition & 1 deletion htdocs/user/class/user.class.php
Expand Up @@ -1285,7 +1285,7 @@ function update($user,$notrigger=0,$nosyncmember=0,$nosyncmemberpass=0)
$sql.= ", login = '".$this->db->escape($this->login)."'";
$sql.= ", api_key = ".($this->api_key ? "'".$this->db->escape($this->api_key)."'" : "null");
$sql.= ", gender = ".($this->gender != -1 ? "'".$this->db->escape($this->gender)."'" : "null"); // 'man' or 'woman'
$sql.= ", admin = ".$this->admin;
if (! empty($user->admin)) $sql.= ", admin = ".$this->admin; // admin flag can be set/unset only by an admin user
$sql.= ", address = '".$this->db->escape($this->address)."'";
$sql.= ", zip = '".$this->db->escape($this->zip)."'";
$sql.= ", town = '".$this->db->escape($this->town)."'";
Expand Down

0 comments on commit c2e853d

Please sign in to comment.