Also log GET/OPTIONS/HEAD requests as device activities.
This commit is contained in:
parent
e10d530d61
commit
1b3190ba6c
1 changed files with 9 additions and 15 deletions
|
@ -113,13 +113,14 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
# check if entry exists / only if write action
|
# check if entry exists / only if write action
|
||||||
|
diff = Time.zone.now - 10.minutes
|
||||||
method = request.method
|
method = request.method
|
||||||
return if method == 'GET'
|
if method == 'GET' || method == 'OPTIONS' || method == 'HEAD'
|
||||||
return if method == 'OPTIONS'
|
diff = Time.zone.now - 30.minutes
|
||||||
return if method == 'HEAD'
|
end
|
||||||
|
|
||||||
# only update if needed
|
# only update if needed
|
||||||
return if session[:user_device_update_at] && session[:user_device_update_at] > Time.zone.now - 5.minutes
|
return if session[:user_device_update_at] && session[:user_device_update_at] > diff
|
||||||
session[:user_device_update_at] = Time.zone.now
|
session[:user_device_update_at] = Time.zone.now
|
||||||
|
|
||||||
UserDevice.action(
|
UserDevice.action(
|
||||||
|
@ -161,10 +162,10 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
# already logged in, early exit
|
# already logged in, early exit
|
||||||
if session.id && session[:user_id]
|
if session.id && session[:user_id]
|
||||||
|
logger.debug 'session based auth check'
|
||||||
userdata = User.lookup(id: session[:user_id])
|
userdata = User.lookup(id: session[:user_id])
|
||||||
current_user_set(userdata)
|
current_user_set(userdata)
|
||||||
|
logger.debug "session based auth for '#{userdata.login}'"
|
||||||
return {
|
return {
|
||||||
auth: true
|
auth: true
|
||||||
}
|
}
|
||||||
|
@ -176,7 +177,6 @@ class ApplicationController < ActionController::Base
|
||||||
sso_userdata = User.sso(params)
|
sso_userdata = User.sso(params)
|
||||||
if sso_userdata
|
if sso_userdata
|
||||||
session[:persistent] = true
|
session[:persistent] = true
|
||||||
|
|
||||||
return {
|
return {
|
||||||
auth: true
|
auth: true
|
||||||
}
|
}
|
||||||
|
@ -185,14 +185,11 @@ class ApplicationController < ActionController::Base
|
||||||
# check http basic based authentication
|
# check http basic based authentication
|
||||||
authenticate_with_http_basic do |username, password|
|
authenticate_with_http_basic do |username, password|
|
||||||
logger.debug "http basic auth check '#{username}'"
|
logger.debug "http basic auth check '#{username}'"
|
||||||
|
|
||||||
userdata = User.authenticate(username, password)
|
userdata = User.authenticate(username, password)
|
||||||
|
|
||||||
next if !userdata
|
next if !userdata
|
||||||
|
|
||||||
current_user_set(userdata)
|
current_user_set(userdata)
|
||||||
user_device_log(userdata, 'basic_auth')
|
user_device_log(userdata, 'basic_auth')
|
||||||
|
logger.debug "http basic auth for '#{userdata.login}'"
|
||||||
return {
|
return {
|
||||||
auth: true
|
auth: true
|
||||||
}
|
}
|
||||||
|
@ -202,17 +199,14 @@ class ApplicationController < ActionController::Base
|
||||||
if auth_param[:token_action]
|
if auth_param[:token_action]
|
||||||
authenticate_with_http_token do |token, _options|
|
authenticate_with_http_token do |token, _options|
|
||||||
logger.debug "token auth check '#{token}'"
|
logger.debug "token auth check '#{token}'"
|
||||||
|
|
||||||
userdata = Token.check(
|
userdata = Token.check(
|
||||||
action: auth_param[:token_action],
|
action: auth_param[:token_action],
|
||||||
name: token,
|
name: token,
|
||||||
)
|
)
|
||||||
|
|
||||||
next if !userdata
|
next if !userdata
|
||||||
|
|
||||||
current_user_set(userdata)
|
current_user_set(userdata)
|
||||||
user_device_log(userdata, 'token_auth')
|
user_device_log(userdata, 'token_auth')
|
||||||
|
logger.debug "token auth for '#{userdata.login}'"
|
||||||
return {
|
return {
|
||||||
auth: true
|
auth: true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue