Small session bug fixes.
This commit is contained in:
parent
4164750ea2
commit
713d96c5e9
3 changed files with 15 additions and 4 deletions
|
@ -10,7 +10,7 @@ class Session extends App.ControllerContent
|
||||||
@load()
|
@load()
|
||||||
@interval(
|
@interval(
|
||||||
=>
|
=>
|
||||||
@load
|
@load()
|
||||||
10000
|
10000
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -110,6 +110,9 @@ class ApplicationController < ActionController::Base
|
||||||
message = 'authentication failed'
|
message = 'authentication failed'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# remember user
|
||||||
|
session[:user_id] = userdata.id
|
||||||
|
|
||||||
# return auth ok
|
# return auth ok
|
||||||
if message == ''
|
if message == ''
|
||||||
|
|
||||||
|
|
|
@ -150,7 +150,7 @@ class SessionsController < ApplicationController
|
||||||
|
|
||||||
def list
|
def list
|
||||||
return if deny_if_not_role('Admin')
|
return if deny_if_not_role('Admin')
|
||||||
sessions = ActiveRecord::SessionStore::Session.order('created_at DESC').limit(10000)
|
sessions = ActiveRecord::SessionStore::Session.order('updated_at DESC').limit(10000)
|
||||||
users = {}
|
users = {}
|
||||||
sessions_clean = []
|
sessions_clean = []
|
||||||
sessions.each {|session|
|
sessions.each {|session|
|
||||||
|
@ -168,10 +168,18 @@ class SessionsController < ApplicationController
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def delete_old
|
||||||
|
ActiveRecord::SessionStore::Session.where('request_type = ? AND updated_at < ?', 1, Time.now - 150.days ).delete_all
|
||||||
|
ActiveRecord::SessionStore::Session.where('request_type = ? AND updated_at < ?', 2, Time.now - 2.days ).delete_all
|
||||||
|
render :json => {}
|
||||||
|
end
|
||||||
|
|
||||||
def delete
|
def delete
|
||||||
return if deny_if_not_role('Admin')
|
return if deny_if_not_role('Admin')
|
||||||
session = ActiveRecord::SessionStore::Session.find(params[:id])
|
session = ActiveRecord::SessionStore::Session.where( :id => params[:id] ).first
|
||||||
|
if session
|
||||||
session.destroy
|
session.destroy
|
||||||
|
end
|
||||||
render :json => {}
|
render :json => {}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue