debian-mirror-gitlab/app/helpers/cookies_helper.rb

20 lines
588 B
Ruby
Raw Normal View History

2018-11-20 20:47:30 +05:30
# frozen_string_literal: true
module CookiesHelper
2020-07-28 23:09:34 +05:30
COOKIE_TYPE_PERMANENT = :permanent
COOKIE_TYPE_ENCRYPTED = :encrypted
2018-11-20 20:47:30 +05:30
2020-07-28 23:09:34 +05:30
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 }
2018-11-20 20:47:30 +05:30
end
end