2019-05-03 08:17:27 +10:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-12-19 18:00:22 +11:00
|
|
|
# session that is not stored in cookie, expires after 1.hour unconditionally
|
|
|
|
class SecureSession
|
|
|
|
def initialize(prefix)
|
|
|
|
@prefix = prefix
|
|
|
|
end
|
|
|
|
|
|
|
|
def [](key)
|
2019-12-03 10:05:53 +01:00
|
|
|
Discourse.redis.get("#{@prefix}#{key}")
|
2016-12-19 18:00:22 +11:00
|
|
|
end
|
|
|
|
|
2017-07-28 10:20:09 +09:00
|
|
|
def []=(key, val)
|
2016-12-19 18:00:22 +11:00
|
|
|
if val == nil
|
2019-12-03 10:05:53 +01:00
|
|
|
Discourse.redis.del("#{@prefix}#{key}")
|
2016-12-19 18:00:22 +11:00
|
|
|
else
|
2019-12-03 10:05:53 +01:00
|
|
|
Discourse.redis.setex("#{@prefix}#{key}", 1.hour, val.to_s)
|
2016-12-19 18:00:22 +11:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|