From 82dd867fdda858c617a8db96151bde4cc7ead555 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20J=C3=A4ggi?= Date: Tue, 31 Dec 2024 13:08:00 +0100 Subject: [PATCH] Add fallback to root group for every primary_group_id case when redirecting --- .../sac_cas/groups/self_registration_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/sac_cas/groups/self_registration_controller.rb b/app/controllers/sac_cas/groups/self_registration_controller.rb index dc2ade7b3..2ae9deb29 100644 --- a/app/controllers/sac_cas/groups/self_registration_controller.rb +++ b/app/controllers/sac_cas/groups/self_registration_controller.rb @@ -56,12 +56,12 @@ def redirect_to_login def redirect_to_memberships_tab flash[:notice] = t("groups.self_registration.create.existing_membership_notice") - redirect_to history_group_person_path(group_id: current_user.primary_group_id, id: current_user.id) + redirect_to history_group_person_path(group_id: current_user.primary_group_id || Group.root.id, id: current_user.id) end def redirect_to_person_show flash[:notice] = t("groups.self_registration.create.existing_family_notice") - redirect_to history_group_person_path(group_id: current_user.primary_group_id, id: current_user.id) + redirect_to history_group_person_path(group_id: current_user.primary_group_id || Group.root.id, id: current_user.id) end def redirect_to_group_if_necessary @@ -70,7 +70,7 @@ def redirect_to_group_if_necessary def redirect_target if current_user.present? - history_group_person_path(group_id: current_user.reload.primary_group_id, id: current_user.id) + history_group_person_path(group_id: current_user.reload.primary_group_id || Group.root.id, id: current_user.id) else new_person_session_path end