mirror of
https://github.com/projectsend/projectsend.git
synced 2026-10-04 05:25:51 +00:00
Land a successful create where a create-only role can actually go
Four create flows redirected to the new record's edit page on success, but store is gated by create_* while the edit page is gated by edit_*, and PermissionChecker has no create-implies-edit rule. A role holding create_* without edit_* would create the record -- write, activity log and notifications all run -- and then meet a 403 on the success redirect, with no way to tell the action worked and every reason to submit a duplicate. Categories is reachable with plain UI clicks, since the sidebar shows it from create_categories alone. Keep landing on the edit page for anyone who may edit, and divert only those who can't -- to the create form, which shares store's own gate and is therefore reachable by exactly whoever just created the record; the success toast shows there. The index would not do: Clients/Groups lists are gated by manage_*, which store itself does not require. Implying edit_* from create_* would not do either -- edit has no own/others split here, so it would silently hand a deliberately narrow create-only role edit (two-factor reset included) on every existing record.
This commit is contained in:
@@ -126,7 +126,12 @@ class UsersController extends Controller
|
||||
'password' => $validated['password'],
|
||||
], $validated['assigned_clients'] ?? []);
|
||||
|
||||
return redirect()->route('users.edit', $user)->with('success', __('User created.'));
|
||||
// Same create-without-edit rule as ClientsController::store().
|
||||
$target = $this->actor()->can('edit_users')
|
||||
? redirect()->route('users.edit', $user)
|
||||
: redirect()->route('users.create');
|
||||
|
||||
return $target->with('success', __('User created.'));
|
||||
}
|
||||
|
||||
public function edit(User $user): Response
|
||||
|
||||
Reference in New Issue
Block a user