Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cookies_helper.rb « helpers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 938379818dedbe72566bf28ab200fb827ef2e27b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

module CookiesHelper
  COOKIE_TYPE_PERMANENT = :permanent
  COOKIE_TYPE_ENCRYPTED = :encrypted

  def set_secure_cookie(key, value, httponly: false, expires: nil, type: nil)
    cookie_jar = case type
                 when COOKIE_TYPE_PERMANENT
                   cookies.permanent
                 when COOKIE_TYPE_ENCRYPTED
                   cookies.encrypted
                 else
                   cookies
                 end

    cookie_jar[key] = { value: value, secure: Gitlab.config.gitlab.https, httponly: httponly, expires: expires }
  end
end