Sha256: a1ae55eb296e83d5082e126011c57da3c5184fdfe0874eced10fa378e86a9f83

Contents?: true

Size: 792 Bytes

Versions: 6

Compression:

Stored size: 792 Bytes

Contents

Warden::Manager.after_authentication do |resource, auth, options|
  if auth.env["action_dispatch.cookies"]
    cookie_value = auth.env["action_dispatch.cookies"].signed[DeviseMultiFactor::REMEMBER_TFA_COOKIE_NAME]
    bypass_by_cookie = DeviseMultiFactor::RememberTFACookie.new.valid_cookie_data?(resource, cookie_value)
  end

  if resource.respond_to?(:need_two_factor_authentication?) && !bypass_by_cookie
    if auth.session(options[:scope])[DeviseMultiFactor::NEED_AUTHENTICATION] = resource.need_two_factor_authentication?(auth.request)
      resource.send_new_otp if resource.send_new_otp_after_login?
    end
  end
end

Warden::Manager.before_logout do |resource, auth, _options|
  auth.cookies.delete DeviseMultiFactor::REMEMBER_TFA_COOKIE_NAME if Devise.delete_cookie_on_logout
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
devise-multi-factor-3.2.5 lib/devise_multi_factor/hooks/two_factor_authenticatable.rb
devise-multi-factor-3.2.4 lib/devise_multi_factor/hooks/two_factor_authenticatable.rb
devise-multi-factor-3.2.3 lib/devise_multi_factor/hooks/two_factor_authenticatable.rb
devise-multi-factor-3.2.2 lib/devise_multi_factor/hooks/two_factor_authenticatable.rb
devise-multi-factor-3.2.1 lib/devise_multi_factor/hooks/two_factor_authenticatable.rb
devise-multi-factor-3.2.0 lib/devise_multi_factor/hooks/two_factor_authenticatable.rb