Skip to content

Commit bfc9306

Browse files
author
twsvaishali
authored
Users with core.create permission should be able create/update the users
1 parent 279c2a7 commit bfc9306

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

src/users/user.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,22 @@ public function post()
3333
$formData = $app->input->getArray();
3434
$userIdentifier = $app->input->get('id', 0, 'string');
3535

36+
if (isset($formData['fields']))
37+
{
38+
$formData['com_fields'] = $formData['fields'];
39+
unset($formData['fields']);
40+
}
41+
3642
// Get current logged in user.
3743
$me = $this->plugin->get('user');
44+
$iAmSuperAdmin = $me->authorise('core.create');
3845

3946
if (!empty($userIdentifier))
4047
{
4148
$user = $this->retriveUser($userIdentifier);
4249

4350
if (!empty($user->id))
4451
{
45-
$iAmSuperAdmin = $me->authorise('core.create');
46-
4752
// Check if regular user is trying to update his/her own profile OR if user is superadmin
4853
if ($me->id == $user->id || $iAmSuperAdmin)
4954
{
@@ -81,6 +86,13 @@ public function post()
8186
// Check if $userIdentifier is not set - POST / CREATE user case
8287
else
8388
{
89+
if (!$iAmSuperAdmin)
90+
{
91+
ApiError::raiseError(400, JText::_('JERROR_ALERTNOAUTHOR'));
92+
93+
return;
94+
}
95+
8496
// Validate required fields
8597
if ($formData['username'] == '' || $formData['name'] == '' || $formData['email'] == '')
8698
{

0 commit comments

Comments
 (0)