From b154cb39f8d0067db68b3f32333d880491fe6a67 Mon Sep 17 00:00:00 2001 From: Sahil Batra Date: Fri, 9 Feb 2024 19:26:54 +0530 Subject: [PATCH] groups: Handle "#groups/new" url for users who cannot create groups. We already do not show the buttons for opening the group creation form if user is not allowed to create group at all, but the user can still open the form by going on "#groups/new" url. This commit fixes this by redirecting such users to "#groups/your" like we do for streams. --- web/src/hash_util.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/web/src/hash_util.ts b/web/src/hash_util.ts index 31f746e9d4..0354fac8c7 100644 --- a/web/src/hash_util.ts +++ b/web/src/hash_util.ts @@ -244,6 +244,11 @@ export function validate_group_settings_hash(hash: string): string { const hash_components = hash.slice(1).split(/\//); const section = hash_components[1]; + const can_create_groups = settings_data.user_can_edit_user_groups(); + if (section === "new" && !can_create_groups) { + return "#groups/your"; + } + if (/\d+/.test(section)) { const group_id = Number.parseInt(section, 10); const group = user_groups.maybe_get_user_group_from_id(group_id);