Commit 8d7033c3 authored by Robert Speicher's avatar Robert Speicher

Merge branch '2366-geo-sign-out-broken' into 'master'

Fix signing out from secondary node when "Remember me" option is checked

Closes #2366

See merge request !1903
parents 40c74cca bcfcdb33
......@@ -52,5 +52,15 @@ module EE
def admin_or_auditor?
admin? || auditor?
end
def remember_me!
return if ::Gitlab::Geo.secondary?
super
end
def forget_me!
return if ::Gitlab::Geo.secondary?
super
end
end
end
---
title: Geo - Fix signing out from secondary node when "Remember me" option is checked
merge_request: 1903
author:
......@@ -1938,4 +1938,36 @@ describe User, models: true do
expect(user.preferred_language).to eq('en')
end
end
describe '#forget_me!' do
subject { create(:user, remember_created_at: Time.now) }
it 'clears remember_created_at' do
subject.forget_me!
expect(subject.reload.remember_created_at).to be_nil
end
it 'does not clear remember_created_at when in a Geo secondary node' do
allow(Gitlab::Geo).to receive(:secondary?) { true }
expect { subject.forget_me! }.not_to change(subject, :remember_created_at)
end
end
describe '#remember_me!' do
subject { create(:user, remember_created_at: nil) }
it 'updates remember_created_at' do
subject.remember_me!
expect(subject.reload.remember_created_at).not_to be_nil
end
it 'does not update remember_created_at when in a Geo secondary node' do
allow(Gitlab::Geo).to receive(:secondary?) { true }
expect { subject.remember_me! }.not_to change(subject, :remember_created_at)
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment