Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #130 from alphagov/bugfix-remote-signout

Bugfix to remote sign-out after gds-sso version bump
  • Loading branch information...
commit 59b7157449c81e5a833e7b71af5e215ea1011bd7 2 parents 4b7cdf4 + 9437186
@vinayvinay vinayvinay authored
Showing with 7 additions and 2 deletions.
  1. +6 −1 app/models/user.rb
  2. +1 −1  test/unit/models/user_test.rb
View
7 app/models/user.rb
@@ -15,7 +15,12 @@ def ability
def self.where(options)
uid = options[:uid]
auth_hash = Rails.cache.fetch(prefixed_key(uid))
- auth_hash ? [ User.new(auth_hash) ] : []
+ return [] unless auth_hash && user_matches?(options, User.new(auth_hash))
+ [ User.new(auth_hash) ]
+ end
+
+ def self.user_matches?(options, user)
+ options.all? { |key, value| user.send(key.to_sym) == value }
end
def self.create!(auth_hash, options={})
View
2  test/unit/models/user_test.rb
@@ -26,7 +26,7 @@ def teardown
user.update_attribute(:remotely_signed_out, true)
assert user.remotely_signed_out?
- assert User.where(uid: "12345").first.remotely_signed_out?
+ assert User.where(uid: "12345", remotely_signed_out: false).empty?
end
should "support mass updating of attributes" do
Please sign in to comment.
Something went wrong with that request. Please try again.