mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2026-01-05 07:10:40 +01:00
Merge branch 'develop' into 1.9
# Conflicts: # CHANGELOG.md # themes/grav/app/updates/index.js # themes/grav/js/admin.min.js
This commit is contained in:
@@ -649,12 +649,12 @@ class Admin
|
||||
$data[$type] = $obj;
|
||||
} elseif (preg_match('|users/|', $type)) {
|
||||
$obj = User::load(preg_replace('|users/|', '', $type));
|
||||
$obj->merge($post);
|
||||
$obj->merge($this->cleanUserPost($post));
|
||||
|
||||
$data[$type] = $obj;
|
||||
} elseif (preg_match('|user/|', $type)) {
|
||||
$obj = User::load(preg_replace('|user/|', '', $type));
|
||||
$obj->merge($post);
|
||||
$obj->merge($this->cleanUserPost($post));
|
||||
|
||||
$data[$type] = $obj;
|
||||
} elseif (preg_match('|config/|', $type)) {
|
||||
@@ -699,6 +699,25 @@ class Admin
|
||||
return $data[$type];
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean user form post and remove extra stuff that may be passed along
|
||||
*
|
||||
* @param $post
|
||||
* @return array
|
||||
*/
|
||||
protected function cleanUserPost($post)
|
||||
{
|
||||
// Clean fields for all users
|
||||
unset($post['hashed_password']);
|
||||
|
||||
// Clean field for users who shouldn't be able to modify these fields
|
||||
if (!$this->authorize(['admin.user', 'admin.super'])) {
|
||||
unset($post['access']);
|
||||
}
|
||||
|
||||
return $post;
|
||||
}
|
||||
|
||||
protected function hasErrorMessage()
|
||||
{
|
||||
$msgs = $this->grav['messages']->all();
|
||||
|
||||
Reference in New Issue
Block a user