docbrown/spec/support/initializers/warden.rb
rhymes bbd56875c7
Rubocop: address feedback of #9430 and use kwargs (#9538)
* Use fetch.to_i

* Rubocop: address feedback of #9430 and use kwargs
2020-07-29 11:13:36 +02:00

22 lines
734 B
Ruby

module Warden
module Test
module Helpers
# Override Warden Test Helper login and logout methods with on_request
# instead of on_next_request in order to prevent the race condition where
# we make a request before the user is finished authenticating
# https://github.com/wardencommunity/warden/blob/a317fde34a6f804bc24efee4bbbe38c76f4cf71e/lib/warden/test/helpers.rb#L19
def login_as(user, **kwargs)
Warden::Manager.on_request do |proxy|
kwargs[:event] ||= :authentication
proxy.set_user(user, **kwargs)
end
end
def logout(*scopes)
Warden::Manager.on_request do |proxy|
proxy.logout(*scopes)
end
end
end
end
end