Skip to content

Commit 29aff2d

Browse files
committed
Allow signing in without a team workgroup
This allows users to sign in to any team that's part of an organisation, even if they're not part of the workgroup for that team. This is necessary to allow release 2.17 to be deployed even if the SAIS teams haven't yet updated their CIS2 workgroups. This change will need to be reverted in 2.18.
1 parent 3187637 commit 29aff2d

File tree

6 files changed

+14
-18
lines changed

6 files changed

+14
-18
lines changed

app/controllers/users/omniauth_callbacks_controller.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ def set_cis2_session_info
109109
role_name: selected_cis2_nrbac_role["role_name"],
110110
role_code: selected_cis2_nrbac_role["role_code"],
111111
workgroups: selected_cis2_nrbac_role["workgroups"],
112-
has_other_roles: raw_cis2_info["nhsid_nrbac_roles"].length > 1
112+
has_other_roles: raw_cis2_info["nhsid_nrbac_roles"].length > 1,
113+
team_workgroup: nil
113114
)
114115
end
115116

app/forms/select_team_form.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def save
3131
def teams
3232
@teams ||=
3333
if Settings.cis2.enabled
34-
cis2_info.organisation.teams.where(workgroup: cis2_info.workgroups)
34+
cis2_info.organisation.teams
3535
else
3636
current_user.teams.includes(:organisation)
3737
end

app/models/cis2_info.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ def organisation
2828

2929
def team
3030
@team ||=
31-
if (workgroup = team_workgroup).present? &&
32-
workgroups&.include?(workgroup)
31+
if (workgroup = team_workgroup).present?
3332
Team.find_by(organisation:, workgroup:)
3433
end
3534
end

spec/features/user_cis2_authentication_with_wrong_organisation_spec.rb

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
given_my_team_has_been_setup_in_mavis
1313
when_i_click_the_change_role_button
14-
then_i_see_the_team_selection_page
14+
then_i_see_the_sessions_page
1515
end
1616

1717
context "user has no other orgs to select" do
@@ -35,7 +35,7 @@ def given_i_am_setup_in_cis2_but_not_mavis
3535
end
3636

3737
def given_my_team_has_been_setup_in_mavis
38-
@team = create :team, ods_code: "A9A5A"
38+
@team = create(:team, ods_code: "A9A5A")
3939
end
4040

4141
def when_i_go_to_the_start_page
@@ -46,10 +46,6 @@ def when_i_click_the_cis2_login_button
4646
click_button "Care Identity"
4747
end
4848

49-
def when_i_click_the_cis2_login_button
50-
click_button "Care Identity"
51-
end
52-
5349
def then_i_am_on_the_start_page
5450
expect(page).to have_current_path start_path
5551
end
@@ -58,8 +54,8 @@ def when_i_go_to_the_sessions_page
5854
visit sessions_path
5955
end
6056

61-
def then_i_see_the_team_selection_page
62-
expect(page).to have_current_path(new_users_teams_path)
57+
def then_i_see_the_sessions_page
58+
expect(page).to have_current_path(sessions_path)
6359
end
6460

6561
def given_i_am_setup_in_cis2_with_only_one_role

spec/features/user_cis2_authentication_with_wrong_role_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
then_i_see_the_wrong_role_error
1010

1111
when_i_click_the_change_role_button_and_select_the_right_role
12-
then_i_see_the_team_selection_page
12+
then_i_see_the_sessions_page
1313
end
1414

1515
def given_i_am_setup_in_mavis_and_cis2_but_with_the_wrong_role
@@ -30,8 +30,8 @@ def when_i_go_to_the_sessions_page
3030
visit sessions_path
3131
end
3232

33-
def then_i_see_the_team_selection_page
34-
expect(page).to have_current_path(new_users_teams_path)
33+
def then_i_see_the_sessions_page
34+
expect(page).to have_current_path(sessions_path)
3535
end
3636

3737
def then_i_see_the_wrong_role_error

spec/features/user_cis2_authentication_with_wrong_workgroup_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
then_i_see_the_wrong_workgroup_error
1010

1111
when_i_click_the_change_role_button_and_select_the_right_role
12-
then_i_see_the_team_selection_page
12+
then_i_see_the_sessions_page
1313
end
1414

1515
def given_i_am_setup_in_mavis_and_cis2_but_with_the_wrong_role
@@ -30,8 +30,8 @@ def when_i_go_to_the_sessions_page
3030
visit sessions_path
3131
end
3232

33-
def then_i_see_the_team_selection_page
34-
expect(page).to have_current_path(new_users_teams_path)
33+
def then_i_see_the_sessions_page
34+
expect(page).to have_current_path(sessions_path)
3535
end
3636

3737
def then_i_see_the_wrong_workgroup_error

0 commit comments

Comments
 (0)