mirror of
https://github.com/internetee/registry.git
synced 2025-05-16 17:37:17 +02:00
Kill inactive sessions after 5 minutes
This commit is contained in:
parent
6a63c258f6
commit
45d62b8f6e
1 changed files with 21 additions and 0 deletions
|
@ -5,6 +5,7 @@ class EppController < ApplicationController
|
|||
|
||||
before_action :generate_svtrid
|
||||
before_action :validate_request
|
||||
before_action :update_epp_session
|
||||
helper_method :current_user
|
||||
|
||||
rescue_from CanCan::AccessDenied do |_exception|
|
||||
|
@ -35,6 +36,26 @@ class EppController < ApplicationController
|
|||
EppSession.find_or_initialize_by(session_id: cookie['session'])
|
||||
end
|
||||
|
||||
def update_epp_session
|
||||
e_s = epp_session
|
||||
return if e_s.new_record?
|
||||
|
||||
if e_s.updated_at < Time.zone.now - 5.minutes
|
||||
@api_user = current_user # cache current_user for logging
|
||||
e_s.destroy
|
||||
response.headers['X-EPP-Returncode'] = '1500'
|
||||
|
||||
epp_errors << {
|
||||
msg: t('session_timeout'),
|
||||
code: '2201'
|
||||
}
|
||||
|
||||
handle_errors and return
|
||||
else
|
||||
e_s.update_column(:updated_at, Time.zone.now)
|
||||
end
|
||||
end
|
||||
|
||||
def current_user
|
||||
@current_user ||= ApiUser.find_by_id(epp_session[:api_user_id])
|
||||
# by default PaperTrail uses before filter and at that
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue