Add default permissions for new users

This commit is contained in:
fipwmaqzufheoxq92ebc 2020-08-28 16:18:21 +02:00
parent 5cb08db737
commit de3907eabc
2 changed files with 13 additions and 1 deletions

View File

@ -172,3 +172,5 @@ Setting('FEATURE_FLAG_CHORES_ASSIGNMENTS', true);
# Feature settings # Feature settings
Setting('FEATURE_SETTING_STOCK_COUNT_OPENED_PRODUCTS_AGAINST_MINIMUM_STOCK_AMOUNT', true); // When set to true opened items will be counted as missing from stock when calculating if a product is below its minimum. Setting('FEATURE_SETTING_STOCK_COUNT_OPENED_PRODUCTS_AGAINST_MINIMUM_STOCK_AMOUNT', true); // When set to true opened items will be counted as missing from stock when calculating if a product is below its minimum.
Setting('FEATURE_FLAG_AUTO_TORCH_ON_WITH_CAMERA', true); // Enables the torch automaticaly in every camera barcode scanner. Setting('FEATURE_FLAG_AUTO_TORCH_ON_WITH_CAMERA', true); // Enables the torch automaticaly in every camera barcode scanner.
Setting('DEFAULT_PERMISSIONS', ['ADMIN']);

View File

@ -12,7 +12,17 @@ class UsersService extends BaseService
'last_name' => $lastName, 'last_name' => $lastName,
'password' => password_hash($password, PASSWORD_DEFAULT) 'password' => password_hash($password, PASSWORD_DEFAULT)
)); ));
return $newUserRow->save(); $newUserRow = $newUserRow->save();
$permList = array();
foreach ($this->getDatabase()->permission_hierarchy()->where('name', GROCY_DEFAULT_PERMISSIONS)->fetchAll() as $perm) {
$permList[] = array(
'user_id' => $newUserRow->id,
'permission_id' => $perm->id
);
}
$this->getDatabase()->user_permissions()->insert($permList);
return $newUserRow;
} }
public function EditUser(int $userId, string $username, string $firstName, string $lastName, string $password) public function EditUser(int $userId, string $username, string $firstName, string $lastName, string $password)