Skip to content

Commit f69e6e4

Browse files
MrSerthnenock
authored andcommitted
fix(nbp): clear session after successful finalize action
Previously, the session was kept intact including the SAML information. This allowed users to return to the connect page, since they were still partially signed in. However, no visual indicator was shown for that state. We decided not to initiate the Single Log-Out via SAML or a regular logout due to the potentially increased complexity and interferences with the NBP IdP.
1 parent 5892f24 commit f69e6e4

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

app/controllers/users/nbp_wallet_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def accept_and_create_user(relationship) # rubocop:disable Metrics/AbcSize
6363

6464
if relationship.accept!
6565
user.send_confirmation_instructions
66+
session.clear # Clear the session to prevent the user from accessing the NBP Wallet page again
6667
redirect_to home_index_path, notice: t('devise.registrations.signed_up_but_unconfirmed')
6768
else
6869
abort_and_refresh(relationship)

spec/requests/users/nbp_wallet/finalize_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
expect(User.order(:created_at).last).not_to be_confirmed
4343
end
4444

45+
it 'clears the session' do
46+
finalize_request
47+
expect(session.keys).to contain_exactly('flash')
48+
end
49+
4550
it 'asks the user to verify the email address' do
4651
finalize_request
4752
expect(response).to redirect_to home_index_path
@@ -72,6 +77,11 @@
7277
it 'does not send a confirmation mail' do
7378
expect { finalize_request }.not_to change(ActionMailer::Base, :deliveries)
7479
end
80+
81+
it 'does not clear the session' do
82+
finalize_request
83+
expect(session.keys).to include('flash', 'omniauth_provider', 'saml_uid', 'session_id')
84+
end
7585
end
7686

7787
shared_examples 'a documented erroneous request' do |error|

0 commit comments

Comments
 (0)