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.
This commit is contained in:
Sahil Batra 2024-02-09 19:26:54 +05:30 committed by Tim Abbott
parent 2fe36cc0d7
commit b154cb39f8
1 changed files with 5 additions and 0 deletions

View File

@ -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);