Sha256: 87e191fd4980dcdb38dd4c5908a9e76934cc7b51ca6aefba776d7088382480e3

Contents?: true

Size: 1.23 KB

Versions: 10

Compression:

Stored size: 1.23 KB

Contents

module Devise
  module Hooks
    # Overwrite success! in authentication strategies allowing users to be remembered.
    # We choose to implement this as an strategy hook instead of a warden hook to allow a specific
    # strategy (like token authenticatable or facebook authenticatable) to turn off remember_me?
    # cookies.
    module Rememberable #:nodoc:
      def success!(resource)
        super

        if succeeded? && resource.respond_to?(:remember_me!) && remember_me?
          resource.remember_me!(extend_remember_period?)

          configuration = {
            :value => resource.class.serialize_into_cookie(resource),
            :expires => resource.remember_expires_at,
            :path => "/"
          }

          configuration[:domain] = resource.cookie_domain if resource.cookie_domain?
          cookies.signed["remember_#{scope}_token"] = configuration
        end
      end

    protected

      def succeeded?
        @result == :success
      end

      def extend_remember_period?
        false
      end

      def remember_me?
        valid_params? && Devise::TRUE_VALUES.include?(params_auth_hash[:remember_me])
      end
    end
  end
end

Devise::Strategies::Authenticatable.send :include, Devise::Hooks::Rememberable

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
devise-1.1.9 lib/devise/hooks/rememberable.rb
devise-1.1.8 lib/devise/hooks/rememberable.rb
devise-1.1.7 lib/devise/hooks/rememberable.rb
devise-1.1.6 lib/devise/hooks/rememberable.rb
devise-1.1.5 lib/devise/hooks/rememberable.rb
devise-1.1.4 lib/devise/hooks/rememberable.rb
devise-1.1.3 lib/devise/hooks/rememberable.rb
devise-1.1.2 lib/devise/hooks/rememberable.rb
devise-1.1.1 lib/devise/hooks/rememberable.rb
devise-1.1.0 lib/devise/hooks/rememberable.rb