From eefe3faa13030b123e0bf8ba6ecdff0c52373157 Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Thu, 27 Oct 2022 17:06:04 +0200 Subject: [PATCH] Re-apply default group when external user signs out --- app/controllers/sessions_controller.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 46360c0f..cf8bc0fc 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -50,6 +50,12 @@ class SessionsController < ApplicationController def destroy if current_user&.external_user? clear_lti_session_data + + # In case we have another session as an internal user, we set the study group for this one + internal_user = find_or_login_current_user + if internal_user.present? + session[:study_group_id] = internal_user.study_groups.find_by(external_id: nil)&.id + end else logout end