fix setting role of user when creating a new user

This commit is contained in:
Uwe Steinmann 2024-04-23 12:38:03 +02:00
parent 06f0e1423b
commit cf786e749a

View File

@ -2053,10 +2053,10 @@ class RestapiController { /* {{{ */
$language = isset($params['language']) ? $params['language'] : null;;
$theme = isset($params['theme']) ? $params['theme'] : null;
$comment = isset($params['comment']) ? $params['comment'] : null;
$role = isset($params['role']) ? $params['role'] : null;
$roleid = $role == 'admin' ? SeedDMS_Core_User::role_admin : ($role == 'guest' ? SeedDMS_Core_User::role_guest : SeedDMS_Core_User::role_user);
$role = isset($params['role']) ? $params['role'] : 3;
$roleobj = $role == 'admin' ? SeedDMS_Core_Role::getInstance(1, $dms) : ($role == 'guest' ? SeedDMS_Core_Role::getInstance(2, $dms) : SeedDMS_Core_Role::getInstance($role, $dms));
$newAccount = $dms->addUser($userName, $password, $fullname, $email, $language, $theme, $comment, $roleid);
$newAccount = $dms->addUser($userName, $password, $fullname, $email, $language, $theme, $comment, $roleobj);
if ($newAccount === false) {
return $response->withJson(array('success'=>false, 'message'=>'Account could not be created, maybe it already exists', 'data'=>''), 500);
}