Sha256: ff487811194c5a45801410a38b7860d1d3d715c15ea89c88ec46203ded22ae39

Contents?: true

Size: 610 Bytes

Versions: 3

Compression:

Stored size: 610 Bytes

Contents

module TheComments
  # Cookies and View token for spam protection
  # include TheComments::ViewToken
  module ViewToken
    extend ActiveSupport::Concern

    included { before_action :set_the_comments_cookies }

    def comments_view_token
      cookies[:comments_view_token]
    end

    private

    def set_the_comments_cookies
      cookies[:the_comment_cookies] = { value: TheComments::COMMENTS_COOKIES_TOKEN, expires: 1.year.from_now }
      cookies[:comments_view_token] = { value: SecureRandom.hex, expires: 7.days.from_now } unless cookies[:comments_view_token]
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
the_comments_ruby-2.3.4 app/controllers/concerns/the_comments/view_token.rb
the_comments_ruby-2.3.3 app/controllers/concerns/the_comments/view_token.rb
the_comments-2.3.1 app/controllers/concerns/the_comments/view_token.rb