Closed H1ghSyst3m closed 11 months ago
Also I forgot to mention When I change the default group from terran to something else, I still can't delete the Group Terran in the Dashboard
Both logs don't show anything.
I am writing it here because I think the Problems are connected, if not please tell me I will open a new Issue.
Chat discussion : https://chat.userfrosting.com/channel/support?msg=ASwCH8JuSiq35unRF
Culprit is here : https://github.com/userfrosting/UserFrosting/blob/ca9cf963888c7eab77769ba51155d6b2c2f97168/app/sprinkles/admin/src/Controller/UserController.php#L623-L624
It shouldn't be the current user group here, but the default group ID. And it must be an ID, since "edit" modal use the same template, and it's comparing ID with ID.
Note it's not as easy as to switch like this :
// Determine if currentUser has permission to modify the group. If so, show the 'group' dropdown.
// Otherwise, set to the currentUser's group and disable the dropdown.
$defaultGroupSlug = $this->config->get('site.registration.user_defaults.group');
$defaultGroup = $this->groupModel::where('slug', $defaultGroupSlug)->firstOrFail();
if ($this->authenticator->checkAccess('create_user_field', [
'fields' => ['group'],
])) {
// Get a list of all groups
$groups = $this->groupModel::all();
} else {
// Get the current user's group
$groups = [$defaultGroup];
$fields['disabled'][] = 'group';
}
// Create a dummy user to pre-populate fields
$user = new $this->userModel([
'group_id' => $defaultGroup->id,
'locale' => $this->config->get('site.registration.user_defaults.locale'),
]);
This could work, however an error would be thrown if the $defaultGroupSlug
doesn't exist in the database. It also need to account "No Group" (empty string in config) could be a valid default group (and the new default in V5).
After consideration, In UF5 this is not really an issue. Default group is not selected when creating a user, but I think this is acceptable.
The real issue is the default group should be set in the database. It would then be easier to set. I'm closing this for now, until group is reworked in a future version.
In the Dashboard -> Users -> [Create User]
The predefined group is always the group of the current logged-in User that is creating the user.
Even when I change in
default.php -> registration.user_defaults.group => 'example group'
As Example when my User is in the Group "Admin" then the predefined Group in the Create User Form is "Admin" and when my Group is "rater" then the predefined Group in the Form is "Rater".
The problem could lie in the file
admin/src/Controller/UserController.php
in the line623
at code: