Add warning when session is invalid (#66)

This commit is contained in:
EarlyZhao 2018-07-19 13:54:36 +08:00 committed by Jason Lee
parent 7aa691d1eb
commit b6c3d3735d
1 changed files with 8 additions and 0 deletions

View File

@ -9,6 +9,7 @@ module RuCaptcha
# session key of rucaptcha
def rucaptcha_sesion_key_key
session_id = session.respond_to?(:id) ? session.id : session[:session_id]
warning_when_session_invalid if session_id.blank?
['rucaptcha-session', session_id].join(':')
end
@ -73,5 +74,12 @@ module RuCaptcha
end
false
end
def warning_when_session_invalid
Rails.logger.warn "
WARNING! The session.id is blank, RuCaptcha can't work properly, please keep session available.
More details about this: https://github.com/huacnlee/rucaptcha/pull/66
"
end
end
end